akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)
 
using ll  = long long;
using ull = unsigned long long;
using P = std::pair<int, int>;
 
int main(int argc, char *argv[])
{
    ll K, A, B;
    std::cin >> K >> A >> B;

    ll ans = 0;
    if (B > A+2) {
        if (A-1 > K) {
            ans = 1+K;
        } else {
            K -= (A-1);
            ans += A;
            if (K % 2 == 0) {
                ans += (K/2) * (B-A); 
            } else {
                ans += (K/2) * (B-A) + 1;
            }
        }
    } else {
        ans = 1+K;
    }

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


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> a(n+1);
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    vector<int> ans(n+1);
    for(int i = n; i >= 1; i--){
        int sum = 0;
        for(int j = i; j <= n; j+=i){
            sum += ans[j];
        }
        if(sum%2 != a[i]){
            ans[i]++;
        }
    }
    int m = 0;
    for(int i = 1; i <= n; i++){
        m += ans[i];
    }
    cout << m << endl;
    for(int i = 1; i <= n; i++){
        if(ans[i] == 1){
            cout << i << " ";
        }
    }
    cout << endl;
    return 0;
}


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

#define all(s) s.begin(), s.end()
#define pb push_back
#define ii pair<int, int>
#define x first
#define y second
#define bit(x, y) ((x >> y) & 1)
#define sz(s) ((int) (s).size())

const int N = 200005;

int n;
vector<int> g[N];
int col[N];
int depth[N];
int cnt[3];
int ans[N];
int coun[3];
vector<int> ver[3];

void dfs(int u, int v, int color) {
    col[u] = color;
    for (int e : g[u]) {
        if (e == v) continue;
        dfs(e, u, 3 - color);
    }
}

int main() {
    ios::sync_with_stdio(false); cin.tie(0); 
    cout.tie(0);
    cin >> n;
    for (int i = 1; i < n; i++) {
        int u, v;
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    for (int i = 1; i <= n; i++) coun[i % 3]++;
    dfs(1, 0, 1);
    for (int i = 1; i <= n; i++) cnt[col[i]]++;
    vector<int> cur = {3, 1, 2};
    bool ok = 0;
    for (int i = 1; i <= 2; i++) {
        if (cnt[i] >= coun[1] + coun[2]) {
            ok = 1;
            for (int j = 1; j <= n; j++) {
                if (col[j] == i) {
                    if (coun[1]) {
                        ans[j] = cur[1];
                        coun[1]--;
                        cur[1] += 3;
                    } else if (coun[2]) {
                        ans[j] = cur[2];
                        coun[2]--;
                        cur[2] += 3;
                    } else {
                        ans[j] = cur[0];
                        cur[0] += 3;
                    }
                } else {
                    ans[j] = cur[0];
                    cur[0] += 3;
                }
            }
            break;
        }
    }
    if (!ok) {
        for (int i = 1; i <= n; i++) {
            if (coun[col[i]]) {
                ans[i] = cur[col[i]];
                cur[col[i]] += 3;
                coun[col[i]]--;
            } else {
                ans[i] = cur[0];
                cur[0] += 3;
            }
        }
        ok = 1;
    }
    if (!ok) cout << -1;
    else {
        for (int i = 1; i <= n; i++) cout << ans[i] << ' ';
    }
    return 0;
}

Measured memory_bytes: 19200
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using big_int = boost::multiprecision::cpp_int;
#define ll long long
#define pb push_back
#define mod 1000000007
#define pi 3.14159265359
#define MAX_CHAR 128
using namespace boost::multiprecision;
using namespace std;

int main() 
{
	//ll i,j,k,x,t;
	string s;
	ll n,k;
	cin>>n>>k;
	ll a[n];
	for(ll i=0;i<n;i++)
	cin>>a[i];
	sort(a,a+n);
	ll sum=0;
	for(ll i=0;i<n-k;i++)
	{
	    sum=sum+a[i];
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 1792
def main():
    H, W = map(int, input().split())
    N = 80 * (H+W) // 2
    A = [list(map(int, input().split())) for _ in range(H)]
    B = [list(map(int, input().split())) for _ in range(H)]
    dp = [[set() for _ in range(W+1)] for _ in range(2)]
    dp[0][1].add(0)
    def ltN(x): return x <= N
    for i in range(H):
        dp[(i+1) & 1] = [set() for _ in range(W+1)]
        for j in range(W):
            diff = abs(A[i][j] - B[i][j])
            tmp = set()
            for x in dp[i & 1][j + 1]:
                tmp.add(abs(x + diff))
                tmp.add(abs(x - diff))
            for x in dp[(i+1) & 1][j]:
                tmp.add(abs(x + diff))
                tmp.add(abs(x - diff))
            dp[(i+1) & 1][j+1] = tmp
    print(min(dp[H & 1][W]))


if __name__ == "__main__":
    main()


Measured memory_bytes: 161928
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    string S, s;

    cin >> S;

    s = string(S.size(), 'x');

    cout << s << endl;

    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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 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 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



signed main(){

    int N, M; cin >> N >> M;
    vec cnt(N + 1, 0);
    int L, R;
    REP(i, M){
        cin >> L >> R;
        cnt[L - 1]++;
        cnt[R]--;
    }
    REP(i, N) cnt[i + 1] += cnt[i];
    int ans = 0;
    REP(i, N) if(cnt[i] == M) ans++;
    Out(ans);

    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
static const int left = -1000000;
static const int right = 1000000;
inline int max(int a, int b) {
    return a > b ? a : b;
}
inline int min(int a, int b) {
    return a < b ? a : b;
}
int main() {
    int K, X;
    scanf("%d %d", &K, &X);
    const int limit = min(right, X + K - 1);
    for (int i = max(left, X - K + 1); i <= limit; i++) printf("%d ", i);
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
using namespace	std;
int main(){

  long long m,n,result=1;

  cin>>m>>n;

  while(n!=1){
    if(n%2) result=(result*m)%1000000007;
    m=(m*m)%1000000007;
    n/=2;
  }

  cout<<(result*m)%1000000007<<endl;

  return 0;

}

Measured memory_bytes: 3080
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

struct Face
{
	int f;
	int a[4];
};
struct Dice
{
	Face f[6];
};

Dice createDice(int k[])
{
	Face d[6];
	d[0].f = k[0];
	d[0].a[0] = k[4];
	d[0].a[1] = k[2];
	d[0].a[2] = k[1];
	d[0].a[3] = k[3];

	d[1].f = k[1];
	d[1].a[0] = k[0];
	d[1].a[1] = k[2];
	d[1].a[2] = k[5];
	d[1].a[3] = k[3];

	d[2].f = k[2];
	d[2].a[0] = k[0];
	d[2].a[1] = k[4];
	d[2].a[2] = k[5];
	d[2].a[3] = k[1];

	d[3].f = k[3];
	d[3].a[0] = k[0];
	d[3].a[1] = k[1];
	d[3].a[2] = k[5];
	d[3].a[3] = k[4];

	d[4].f = k[4];
	d[4].a[0] = k[0];
	d[4].a[1] = k[3];
	d[4].a[2] = k[5];
	d[4].a[3] = k[2];

	d[5].f = k[5];
	d[5].a[0] = k[1];
	d[5].a[1] = k[2];
	d[5].a[2] = k[4];
	d[5].a[3] = k[3];
	Dice dice;
	REP(i, 6)
	{
		dice.f[i] = d[i];
	}
	return dice;
}

int main()
{
	Dice d[105];

	int n;
	cin >> n;
	int sum = 0;
	REP(i, n)
	{
		int x[6];
		
		REP(j, 6)
		{
			cin >> x[j];
			sum += x[j];
		}

		
		d[i] = createDice(x);
	}

	if (sum == 22)
	{
		cout << "No" << endl;
		return 0;
	}
	string S = "Yes";

	REP(i, n)
	{
		FOR(j, n, i + 1)
		{
			bool same = true;
			REP(k, 6)
			{
				Face f1 = d[i].f[k];
				REP(l, 6)
				{
					Face f2 = d[j].f[l];
					if (f1.f == f2.f)
					{
						int s = -1;
						REP(m, 4)
						{
							if (f1.a[0] == f2.a[m])
							{
								s = m;
								break;
							}
						}
						if (s == -1)
						{
							same = false;
							break;
						}
						REP(m, 4)
						{
							if (f1.a[m] != f2.a[(m + s) % 4])
							{
								same = false;
								break;
							}
						}
						break;
					}
					if (l == 5)
					{
						same = false;
					}
				}
			}
			if (same)
			{
				S = "No";
				break;
			}
		}
	}

	cout << S << endl;
	return 0;
}


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


void solve(long long N, long long A, long long B){
    cout << min(N * A, B) << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(N, A, B);
    return 0;
}


Measured memory_bytes: 3660
N=int(input())
L=list(map(int,input().split()))
L.sort()
ans=0
for i in range(N):
    for j in range(i+1,N):
        if L[i]==L[j]:
            continue
        for k in range(j+1,N):
            if L[j]==L[k]:
                continue
            if L[i]+L[j]>L[k]:
                ans+=1
print(ans)


Measured memory_bytes: 9080
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        int itemCOunt = int.Parse(Reader.ReadLine());
        long[] items = Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).OrderBy(a=>a). ToArray();
        Dictionary<long, int> cnt = new Dictionary<long, int>();
        for (int i = 0; i < items.Length;i++) {
            if(cnt.ContainsKey(items[i])) {
                cnt[items[i]]++;
            } else {
                cnt[items[i]] = 1;
            }
        }

        long ans = 0;
        foreach(long key in cnt.Keys) {
            if(cnt[key]>key) {
                ans += cnt[key] - key;
            } else if(cnt[key]<key) {
                ans += cnt[key];
            }
        }

        Console.WriteLine(ans);
    }


    public class Reader
    {
        private static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"


8
2 7 1 8 2 8 1 8



";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 32348
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll gya[1000010];
ll kai[1000010];
ll beki(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k%2==1){
            ret*=now;
            ret%=mod2;
        }
        now*=now;
        now%=mod2;
        k/=2;
    }
    return ret;
}
ll gyaku(ll n){
    return beki(n,mod-2);
}
void nckinit(ll n){
    kai[0]=1;
    kai[1]=1;
    for(int i=2;i<=n;i++){
        kai[i]=kai[i-1]*i;
        kai[i]%=mod;
    }
    gya[n]=gyaku(kai[n]);
    for(int i=n-1;i>=1;i--){
        gya[i]=gya[i+1]*(i+1);
        gya[i]%=mod;
    }
    gya[0]=1;
}
ll nck(ll n,ll k){
    if(k<0)return 0;
    if(k==0||n==k)return 1;
    ll ret=kai[n];
    ret*=gya[n-k];
    ret%=mod;
    ret*=gya[k];
    ret%=mod;
    return ret;
}
ll npk(ll n,ll k){
    if(k<0)return 0;
    if(k==0)return 1;
    ll ret=kai[n];
    ret*=gya[n-k];
    ret%=mod;
    return ret;
}
ll dat[800010];
ll u;
void seginit(ll n){
  ll y=1;
  for(int i=0;;i++){
    
    if(y>=n){
      u=y;
      break;
    }
    y*=2;
  }
  fill(dat,dat+2*u,inf);
}
void add(ll n,ll x){
  ll i=n+u-1;
  dat[i]=x;
  while(i>0){
    i=(i-1)/2;
    dat[i]=min(dat[2*i+1],dat[i*2+2]);
  }
}
ll que(ll a,ll b,ll k,ll l,ll r){
  if(a>=r||b<=l)return inf;
  if(a<=l&&b>=r)return dat[k];
  ll m1=que(a,b,2*k+1,l,(l+r)/2);
  ll m2=que(a,b,2*k+2,(l+r)/2,r);
  return min(m1,m2);
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    ll n,m;cin>>n>>m;
    vector<pll> v[n+1];
    rep(i,0,m){
        ll l,r,c;cin>>l>>r>>c;
        l--;
        r--;
        v[l].push_back({r,c});
        
    }
    seginit(n+1);
    ll dp[n+1];
    fill(dp,dp+n+1,inf);
    add(0,0);
    rep(i,0,n){
        ll uu=que(i,u,0,0,u);
        if(uu==inf){
            cout<<-1<<endl;
            return 0;
        }
        dp[i]=uu;
        rep(j,0,v[i].size()){
            ll ne=v[i][j].first;
            ll co=v[i][j].second;
            ll ata=dat[ne+u-1];
            if(ata>dp[i]+co){
            add(ne,dp[i]+co);
            }
        }
    }
    cout<<dp[n-1]<<endl;
   //rep(i,0,n)cout<<dp[i]<<" ";
}


Measured memory_bytes: 10496
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int s = Integer.parseInt(sc.next());
		sc.close();

		ArrayList<Integer> list = new ArrayList<>();
		Set<Integer> checkSet = new HashSet<>();
		list.add(s);
		checkSet.add(s);
		int i = 0;
		while(list.size() == checkSet.size()) {
			int a = list.get(i);
			if(a % 2 == 0) {
				int tmp = a / 2;
				list.add(tmp);
				checkSet.add(tmp);
			}else {
				int tmp = 3 * a + 1;
				list.add(tmp);
				checkSet.add(tmp);
			}
			i++;
		}
		System.out.println(i + 1);
	}

}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	string S;
	cin >> S;
	bool flag = S.size() % 2 == 0;
	for (int i = 0; i < S.size(); i++) {
		flag &= ((i & 1) && S[i] == 'i' || !(i & 1) && S[i] == 'h');
	}
	cout << (flag ? "Yes" : "No") << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 256
n, m = map(int, input().split())
student = [tuple(map(int, input().split())) for _ in range(n)]
check = [tuple(map(int, input().split())) for _ in range(m)]

for x, y in student:
    d = 10 ** 18
    ans = -1
    for i, (a, b) in enumerate(check):
        if d > abs(x - a) + abs(y - b):
            d = abs(x - a) + abs(y - b)
            ans = i+1
    print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if (a < b && b < c) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 26160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define MOD 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
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;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main() {
    ll N;
    cin >>N;
    vector<ll>A(N);
    ll flag=0;
    if(N%2==0){
       rep(i,N){
            ll a;
            cin>>a;
       
            A[a]++;
            if(a%2==0){
                flag==1;
            }else if(A[a]>2){
                flag=1;
            }
        }
    }else{
        rep(i,N){
            ll a;
            cin>>a;
        
            A[a]++;
            if(a%2==1){
                flag==1;
            }else if(A[a]>2||(a==0&&A[a]>1)){
                flag=1;
            }
        }
    }
    if(flag==1){
        cout<<0<<endl;
    }else{
        cout<<modpow(2,N/2,MOD)<<endl;;
    }



    return 0;
    

}

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

using namespace std;
int main() {
  int N,ans=0;
  string S;
  cin>>N>>S;
  
  for(int i=0;i<N;i++){
    int cnt=0;
    for(char c='a';c<='z';c++){
      bool L=false,R=false;
      for(int j=0;j<i;j++){
        if(S[j]==c) L=true;
      }
      for(int j=i;j<N;j++){
        if(S[j]==c) R=true;
      }
      if(L&&R) cnt++;
    }
    ans=max(ans,cnt);
  }
  cout<<ans<<endl;
}	

Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<functional>
#include<algorithm>
using namespace std;

priority_queue<int,vector<int>,less<int> > L;
priority_queue<int,vector<int>,greater<int> > R;


int main(){
    int Q,op,cnt=0,a,b;
    long long sum_L=0,sum_R=0,sum_b=0;
    scanf("%d",&Q);
    for(;Q>0;Q--){
    	scanf("%d",&op);
    	if(op==2){
    		printf("%d %lld\n",L.top(),sum_R-sum_L+sum_b);
    	}
    	if(op==1){
    		scanf("%d%d",&a,&b);
    		sum_b+=b;
    		cnt++;
    		if(cnt==1){
    			L.push(a);
    			R.push(a);
    			sum_L+=a;
    			sum_R+=a;
    		}
    		else if(cnt%2==1){
    			if(a<L.top()){
    				R.push(L.top());
    				sum_R+=L.top();
    				L.push(a);
    				sum_L+=a;
    			}
    			else if(a>R.top()){
    				L.push(R.top());
    				sum_L+=R.top();
    				R.push(a);
    				sum_R+=a;    				
    			}
    			else{
     				L.push(a);
    				sum_L+=a;
    				R.push(a);
    				sum_R+=a;       				
    			}
    		}
    		else if(cnt%2==0){
    			if(a<L.top()){
    				sum_L-=L.top();
    				L.pop();
    				L.push(a);
    				sum_L+=a;
    			}
    			else{
    				sum_R-=R.top();
    				R.pop();
    				R.push(a);
    				sum_R+=a;  				
    			}
    		}
    	}
    }
    return 0;
}

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

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

    set<char> dict;
    for (int i = 0; i < S.size(); i++)
    {
        dict.insert(S[i]);
    }
    if (S.size() == dict.size())
    {
        cout << "yes" << endl;
    }
    else
    {
        cout << "no" << endl;
    }
}


Measured memory_bytes: 256
import math


def main():
    n, d = map(int, input().split())
    x = []
    ans = 0
    for i in range(n):
        x.append(list(map(int, input().split())))
    for i in range(n - 1):
        for j in range(i + 1, n):
            distance_pow = 0
            for k in range(d):
                distance_pow += (x[i][k] - x[j][k]) ** 2
            if math.sqrt(distance_pow) % 1 == 0:
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
from collections import deque

H, W = map(int, input().split())
C = [['#' for j in range(W + 2)] for i in range(H + 2)]

for i in range(H):
    s = input()
    for j in range(W):
        C[i + 1][j + 1] = s[j]
ans = 0

for sy in range(1, H + 1):
    for sx in range(1, W + 1):

        q = deque()
        q.append((sy, sx, 0))
        S = set([])
        while len(q) > 0:
            t = q.popleft()
            y, x, d = t[0], t[1], t[2]
            ans = max(d, ans)
            if C[y][x] == '#':
                continue
            if (y, x) in S:
                continue
            else:
                S.add((y, x))

            q.append((y + 1, x , d + 1))
            q.append((y - 1, x, d + 1))
            q.append((y, x + 1, d + 1))
            q.append((y, x - 1, d + 1))




print(ans - 1)




Measured memory_bytes: 3316
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	s, t := nextLine(), nextLine()
	fmt.Println(t + s)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextByte() []byte {
	sc.Scan()
	return sc.Bytes()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 58;
const int MOD = 1000000007;
const int MAX_N = 200100;

int counter[10000];
signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int N, P;
    cin >> N >> P;
    string S;
    cin >> S;

    REP(i, P)
    {
        counter[i] = 0;
    }

    if (P == 2)
    {
        int ans = 0;
        REP(i, N)
        {
            int c = S[i] - '0';
            if (c % 2 == 0)
            {
                ans += i + 1;
            }
        }
        cout << ans << endl;
    }
    else if (P == 5)
    {
        int ans = 0;
        REP(i, N)
        {
            int c = S[i] - '0';
            if (c == 0 || c == 5)
            {
                ans += i + 1;
            }
        }
        cout << ans << endl;
    }
    else
    {
        int ten = 1;
        int tmp = 0;
        for (int i = 1; i <= N; ++i)
        {
            int c = S[N - i] - '0';
            tmp += ten * c;
            tmp %= P;
            counter[tmp]++;
            ten *= 10;
            ten %= P;
        }
        int ans = 0;
        REP(i, P)
        {
            if (i == 0)
            {
                ans += counter[i];
            }
            if (counter[i] > 1)
                ans += (counter[i] * (counter[i] - 1) / 2);
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 1000010
/* ちゃんと考えてわかって実装 */

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

    vector<int> A(n+1);
    map<int, ll> mp_n;
    map<int, ll> mp_c;
    for(int i=1; i<=n; i++){
        cin >> A[i];
        mp_c[A[i]] += mp_n[A[i]];
        mp_n[A[i]] += 1;
    }


    ll pre_ans = 0;
    for(int i=1; i<=n; i++){
        mp_n[i]--;
        pre_ans += mp_c[i];
    }

    for(int i=1; i<=n; i++){
        ll ans = pre_ans - mp_n[A[i]];
        cout << ans << endl;
    }
    return 0;
}

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

#define int long long
#define pb push_back
#define range(v) v.begin(),v.end()
#define mod (int)(1e9 + 7)
#define inf (int)(1e15)
#define N (int)(3e6 + 10)

using namespace std;

void solve() {
    int n;
    cin >> n;

    int val = 0;

    for (int i = 1; i <= N; i++) {
        val = ((val * 10) % n + 7) % n;
        if (!val) {
            cout << i << endl;
            return;
        }
    }

    cout << -1 << endl;
}

// you should probably see down .. believe me it would help
int32_t main() {
    ios_base::sync_with_stdio(false), cin.tie(nullptr), cin.tie(nullptr);
    int t_c = 1;
//    cin >> t_c;
    while (t_c--)
        solve();
}

// COME ON DUDE .... GIVING UP NOT GONNA HELP
// JUST GET YOUR ASS TO WORK ALREADY ..
// AND FOR FUCKING SAKE ... DONT PANIC !!


Measured memory_bytes: 3660
#include <cstdio>
#include<cstring>
using namespace std;

int main()
{
    char s[1000];
    scanf("%s",s);
    if(strlen(s)==3)
    {
        if(s[0]+s[1]+s[2]=='a'+'b'+'c')
            printf("Yes\n");
        else printf("No");
    }
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> v(n + 1);
    int sum = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> v[i];
        sum += v[i];
    }
    double ave = (double)sum / n;
    double ans = INF;
    int pos;
    for(int i = 0; i < n; i++)
    {
        double tmp = abs(v[i] - ave);
        if(tmp < ans)
        {
            ans = tmp;
            pos = i;
        }
    }
    cout << pos << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<int,long long>sum;
int a[200005];
long long sss(long long n){
    if(n<=1) return 0;
    long long a=n*(n-1)/2;
    return a;
}
int main(){
    int n;
    long long s=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        sum[a[i]]++;
    }
    map<int,long long>::iterator it;
    for(it=sum.begin();it!=sum.end();it++)
        s=s+sss(it->second);
    for(int i=0;i<n;i++){
        if(sum[a[i]]>=2){
            printf("%lld\n",s-sss(sum[a[i]])+sss(sum[a[i]]-1));
            continue;
        }
        printf("%lld\n",s);
    }
    return 0;
}

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

int main()
{
	string s, c, p;
	int q, a, b;

	cin >> s >> q;
	while (q--) {
		cin >> c >> a >> b;
		int l = b - a + 1;
		if (c == "print")
			cout << s.substr(a, l) << endl;
		else if (c == "reverse")
			reverse(s.begin() + a, s.begin() + b + 1);
		else {
			cin >> p;
			s = s.replace(a, l, p);
		}
	}

	return 0;
}


Measured memory_bytes: 3244
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const long long  mod = 1000000007;



int main(){
  int h,w;
  cin >> h >> w;

  map<int,int> s;
  multiset<int> v;

  rep(i,w) s[i] = i;
  rep(i,w) v.insert(0);

  rep(i,h){
    int r,l;
    cin >> l >> r;
    l--;

    auto it = s.lower_bound(l);
    int mr = -1;
    while(it != s.end() && it->first <=r){
      mr = max(mr, it->second);
      int x = it->first - it->second;
      v.erase(v.find(x));
      s.erase(it++);
      if(r > w-1) mr = -1;
    }
    if(mr != -1) {
      v.insert(r-mr);
      s[r] = mr;
    }
    int ans = -1;
    if(v.size()>0) {
      ans = *v.begin() + i+1;
    }
    cout << ans << endl;
  }
}


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

using namespace std;


namespace XDYIMCMI0LY {
  void main() {
    int n;
    int k;
    cin >> n >> k;
    // if (n == k) {
    //   cout << 1 << endl;
    //   return;
    // }
    // cout << (int) ceil((double) n / (k - 1)) << endl;
    // return;
    int pos;
    for (int i = 1, x; i <= n; ++i) {
      cin >> x;
      if (x == 1) {
        pos = i;
      }
    }
    int l = pos;
    int r = l + k - 1;
    int ans = 10000000;
    for (int i = 1; i <= k; ++i) {
      if (l >= 1 && r <= n && l <= pos && r >= pos) {
        ans = min(ans, (int) (ceil((double)(l - 1) / (k - 1))) + (int) (ceil((double) (n - r) / (k - 1))));
      }
      --l;
      --r;
    }
    cout << ans + 1 << endl;
    return ;
  }
}

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


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <utility>

using namespace std;

#define MAX 20

bool map[MAX + 2][MAX + 2];
bool visited[MAX + 2][MAX + 2];

int vs[] = {0, 1, 0, -1};

int main() {
	
	while(true){
		int W, H;
		cin >> W >> H;
		
		if(W == 0 && H == 0){
			break;
		}
		
		for(int i = 0; i < MAX + 2; i++){
			for(int j = 0; j < MAX + 2; j++){
				map[i][j] = false;
				visited[i][j] = false;
			}
		}
		
		int rx = -1, ry = -1;
		for(int i = 0; i < H; i++){
			string line;
			cin >> line;
			
			for(int j = 0; j < W; j++){
				if(line[j] != '#'){
					map[i + 1][j + 1] = true;
					
					if(line[j] == '@'){
						rx = j + 1;
						ry = i + 1;
					}
				}
			}
		}
		
		queue<pair<int, int> > queue;
		queue.push(pair<int, int>(rx, ry));
		visited[ry][rx] = true;
		int count = 0;
		while(!queue.empty()){
			pair<int, int> point = queue.front();
			queue.pop();
			count++;
			
			const int x = point.first;
			const int y = point.second;
			
			for(int i = 0; i < 4; i++){
				const int nx = x + vs[i];
				const int ny = y + vs[(i + 1) % 4];
				
				if(visited[ny][nx]){ continue; }
				if(!map[ny][nx]) { continue; }
				
				queue.push(pair<int, int>(nx, ny));
				visited[ny][nx] = true;
			}
		}
		
		cout << count << endl;
	}
	

	return 0;
}

Measured memory_bytes: 1232
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<numeric>
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}
bool isDigit(char c){return '0' <= c && c <= '9';}
template<typename T> void remove(std::vector<T>& vector, unsigned int index){vector.erase(vector.begin() + index);}
//priority_queue<int, vi, greater<int> > que;//昇順

using namespace std;

const int mod=1e9+7;

signed main(){
    SPEED;
    int h,w;
    cin >> h >> w;
    vector<char> c(w);
    rep(i,h)
    {
        rep(j,w)cin >> c[j];
        rep(j,w)cout << c[j];
        cout << endl;
        rep(j,w)cout << c[j];
        cout << endl;
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

using namespace std;

int n;
string s;

void solve();

int main() {
  cin >> n;
  cin >> s;
  solve();
}

void solve() {
  vector<vector<int>> dp(n);
  // index out of range しないように１つ余分にとる
  dp.assign(n + 1, vector<int>(n + 1, 0));

  for (int i = n - 1; i >= 0; i--) {
    for (int j = n - 1; j >= 0; j--) {
      if (s[i] == s[j]) {
        dp[i][j] = dp[i + 1][j + 1] + 1;
      }
    }
  }

  int max_val = 0;
  rep(i, n) {
    rep(j, n) {
      if (i >= j) {
        // i < j であることを保証する
        continue;
      }
      // j - i より大きいときは重なるので条件に反するため
      int limit = j - i;
      int now = min(dp[i][j], limit);
      max_val = max(max_val, now);
    }
  }

  cout << max_val << endl;
}


Measured memory_bytes: 98304
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class A
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var C = Scanner.Scan<char>();
            Console.WriteLine(char.IsUpper(C) ? "A" : "a");
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
            public static IEnumerable<T> ScanEnumerable<T>() => Console.ReadLine().Trim().Split(" ").Select(x => (T)Convert.ChangeType(x, typeof(T)));
        }
    }
}


Measured memory_bytes: 26648
N = int(input())
abc = [list(map(int, input().split())) for i in range(N)]
dpa = [abc[0][0]] + [0] * N
dpb = [abc[0][1]] + [0] * N
dpc = [abc[0][2]] + [0] * N
for i in range(1, N):
    dpa[i] = max(dpb[i-1], dpc[i-1]) + abc[i][0]
    dpb[i] = max(dpa[i-1], dpc[i-1]) + abc[i][1]
    dpc[i] = max(dpa[i-1], dpb[i-1]) + abc[i][2]

print(max(dpa[N-1], dpb[N-1], dpc[N-1]))
    
    

Measured memory_bytes: 94508
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define FORD(x,y,z) for(int x=y;x>=z;x--)
#define MSET(x,y) memset(x,y,sizeof(x))
#define FOR(x,y) for(__typeof(y.begin()) x=y.begin();x!=y.end();x++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 1000005
void RI(){}
template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}
using namespace std;
typedef long long LL;
int n,c1[30],c2[30];
char buf[M];
int main()
{
	RI(n);
	
	scanf("%s", buf+1);
	REP(i,1,n) c1[buf[i]-'a']++;
	
	scanf("%s", buf+1);
	REP(i,1,n) c2[buf[i]-'a']++;

	sort(c1,c1+26);
	sort(c2,c2+26);
	int ans=0;
	REP(i,0,25) ans += abs(c1[i] - c2[i]);
	printf("%d\n", ans/2);
	return 0;
}

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  for(int i = 1; i <= B; ++i) {
    if((A * i) % B == C) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<bitset>
using namespace std;
const int inf = 1001001000;

void print(vector<vector<int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

//素数かどうかを判定する関数.未検証
int isprime(long long int n){
	if (n == 1) return 0;
    if (n == 2) return 1;
    for (int i=2;i < sqrt(n)+1;i++){
        if (n % i == 0) return 0;
    }
    return 1;
}

int main(){
	int q; cin >> q;
	int n = 1e5+1;
	vector<int> c(n,0);
	vector<int> p(n,0);
	for (int i = 1; i < n; i++){
		if (isprime(i) == 1){
			if (isprime((i+1)/2) == 1){
				p[i] = 1;
			}
		}
	}
	for (int i = 1; i < n - 1; i++){
		c[i+1] = c[i] + p[i+1];
	}
	for (int i = 0;i < q; i++){
		int l, r; cin >> l >> r;
		cout << c[r] - c[l-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>

int main(){
	
	int N;
	std::cin >> N;

	std::string S;

	std::cin >> S;

	int prefixcount = 0, topcount = 0;

	for (char c : S) {
		prefixcount += c == '(' ? 1 : -1;
		if (prefixcount < 0) {
			++topcount;
			prefixcount = 0;
		}
	}


	int botcount = prefixcount;
	for (int i = 0; i < topcount; ++i) {
		std::cout << '(';
	}

	std::cout << S;

	for (int i = 0; i < botcount; ++i) {
		std::cout << ')';
	}

	std::cout << std::endl;

	return 0;
}



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

/**
 * 挿入ソート
 * @author nobu
 * @see <a href="http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_A&lang=ja">ALDS1_2_A</a>
 */
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];

		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		int count = bubbleSort(a, n);

		System.out.println(Arrays.toString(a).replace("[", "").replace("]", "").replace(",", ""));
		System.out.println(count);

		sc.close();
	}

	private static int bubbleSort(int[] a, int n) {
		int count = 0;
		boolean flg = true;
		while (flg) {
			flg = false;
			for (int i = n - 1; 0 < i; i--) {
				if (a[i] < a[i - 1]) {
					int tmp = a[i - 1];
					a[i - 1] = a[i];
					a[i] = tmp;
					flg = true;
					count++;
				}
			}
		}
		return count;
	}

}



Measured memory_bytes: 26368
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    S = SS()

    ans = '2018' + S[4:]
    print(ans)

if __name__ == '__main__':
    resolve()


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

using namespace std;

typedef long long int LL;

int main() {
    LL n, h;
    cin >> n >> h;
    vector<LL> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }

    sort(a.begin(), a.end(), greater<LL>());
    sort(b.begin(), b.end(), greater<LL>());

    LL cnt = 0;
    for (int i = 0; i < n && b[i] > a[0]; i++) {
        h -= b[i];
        cnt++;
        if (h <= 0) break;
    }

    if (h <= 0) {
        cout << cnt << endl;
        return 0;
    }

    cout << cnt + (h + a[0] - 1) / a[0] << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using P = pair<int,int>;

int main(){
  int h, w;
  cin >> h >> w;
  vector<string> hw(h);
  for(int i=0; i<h; ++i) cin >> hw[i];
  queue<P> que;
  vector<vector<int>> dis(h, vector<int>(w, -1));
  for(int i=0; i<h; ++i) for(int j=0; j<w; ++j){
    if(hw[i][j] == '#'){
      que.push(make_pair(i,j));
      dis[i][j] = 0;
    }
  }
  int ans = 0;
  while(!que.empty()){
    int x, y;
    tie(x,y) = que.front();
    que.pop();
    if(x>0 && dis[x-1][y] == -1){
      dis[x-1][y] = dis[x][y] + 1;
      ans = max(ans, dis[x-1][y]);
      que.push(make_pair(x-1,y));
    }
    if(x<h-1 && dis[x+1][y] == -1){
      dis[x+1][y] = dis[x][y] + 1;
      ans = max(ans, dis[x+1][y]);
      que.push(make_pair(x+1,y));
    }
    if(y>0 && dis[x][y-1] == -1){
      dis[x][y-1] = dis[x][y] + 1;
      ans = max(ans, dis[x][y-1]);
      que.push(make_pair(x,y-1));
    }
    if(y<w-1 && dis[x][y+1] == -1){
      dis[x][y+1] = dis[x][y] + 1;
      ans = max(ans, dis[x][y+1]);
      que.push(make_pair(x,y+1));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 17024
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<assert.h>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main() {
	string s;
	cin >> s;
	string ye = "2018";

	cout << ye;
	for (int i = 4; i < s.size(); i++) {
		cout << s[i];
	}
	cout << "\n";
	return 0;
}





Measured memory_bytes: 384
n=int(input())
a=list(map(int, input().split()))
a_s=sorted(a)
for i in range(0,n-1,2):
    if a_s[i]<0 and a_s[i+1]<0:
        a_s[i]=-a_s[i]
        a_s[i+1]=-a_s[i+1]
    elif a_s[i]<0 and -a_s[i]>a_s[i+1]:
        a_s[i]=-a_s[i]
        a_s[i+1]=-a_s[i+1]
    else:
        break
print(sum(a_s))

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

int main(void){
	int a, b, k;
  	cin >> k;
 	cin >> a >> b;
  	if(a+(k-(a%k)) <= b || a%k == 0) cout << "OK";
  	else cout << "NG";
	return 0;
}


Measured memory_bytes: 3596
def readinput():
    n,m=list(map(int,input().split()))
    lmpSw=[]
    for _ in range(m):
        l=list(map(int,input().split()))
        lmpSw.append(l[1:])
    p=list(map(int,input().split()))
    return n,m,lmpSw,p

def main(n,m,lmpSw,p):
    lmpSwBit=[0]*m
    for i in range(m):
        swBit=0
        for sw in lmpSw[i]:
            swBit+=2**(sw-1)
        lmpSwBit[i]=swBit

    lmpStat=[]
    for i in range(m):
        stat=[0 for x in range(2**n)]
        lmpStat.append(stat)
    # lmpStat[m][swStat]

    allon=0
    for swStat in range(2**n):
        # スイッチの全状態をスキャン
        count=0
        for lmp in range(m):
            # 全電球についてループ
            swBit=lmpSwBit[lmp]
            b=1
            for sw in range(n):            
                if(swBit&b==b) and (swStat & b)==b:
                    lmpStat[lmp][swStat]+=1
                b=b*2
            lmpStat[lmp][swStat]+=p[lmp]
            if(lmpStat[lmp][swStat]%2==0):
                count+=1
        if(count==m):
            allon+=1
    return allon


if __name__=='__main__':
    n,m,lmpSw,p=readinput()
    ans=main(n,m,lmpSw,p)
    print(ans)


Measured memory_bytes: 3188
class BIT:
    def __init__(self, n):
        #A1 ... AnのBIT(1-indexed)
        self.BIT = [0] * (n + 1)
        self.n = n

    #A1 ~ Aiまでの和 O(logN)
    def query(self, idx):
        res_sum = 0
        while idx > 0:
            res_sum += self.BIT[idx]
            idx -= idx & (-idx)
        return res_sum

    #Ai += x O(logN)
    def add(self, idx, x):
        while idx <= self.n:
            self.BIT[idx] += x
            idx += idx&(-idx)
        return
def get_int(f):
    if "." not in f:
        return int(f),0
    return int(f.replace(".","")),len(f)-f.index(".")-1
n = int(input())
p = []
for i in range(n):
    a, b = get_int(input())
    c, d = 0, 0
    while a % 2 == 0:
        c += 1
        a //= 2
    while a % 5 == 0:
        d += 1
        a //= 5
    c -= b
    d -= b
    p.append((c, d))
p.sort()
now = n - 1
t = BIT(50)
ans = 0
for i in range(n):
    for j in range(now, i, -1):
        if p[i][0] + p[j][0] >= 0:
            t.add(-p[j][1] + 25, 1)
            now -= 1
        else:
            break
    if now < i:
        t.add(-p[i][1] + 25, -1)
    ans += max(0, t.query(25 + p[i][1]))

print(ans)

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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
//vector<vector<int>> z(n,vector<int>(2));
//n番目から数えてm個の文字列をXに置換したい場合はreplace(n,m,X) teWttest
//s1.substr(3,3);
//n番目以降の文字列をm個取り出す、上だとtte

int main(){
  ll a,b;
  cin>>a>>b;

  ll c;
  c=gcd(a,b);
  vector<pair<ll, ll>> res;

  for(ll i=2;i*i<=c;i++){
  //  cout<<i<<endl;
    if(c%i)continue;
    res.push_back(make_pair(i,0));
    while (c%i==0){
      c/=i;
      res.back().second++;
    }
  }
  if (c!=1) res.push_back(make_pair(c,1));
  ll ans;
  ans=res.size()+1;
  cout<<ans;


  }


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

int main() {
    string s;
    cin >> s;
    int prefix = stoi(s.substr(0,2));
    int suffix = stoi(s.substr(2,2));

    bool YYMM = false;
    bool MMYY = false;
    if (prefix < 1 || 12 < prefix) {
        MMYY = true;
    }
    if (suffix < 1 || 12 < suffix) {
        YYMM = true;
    }
    if (YYMM == true && MMYY == true) {
        cout << "NA" << endl;
    } else if (YYMM == true && MMYY == false) {
        cout << "MMYY" << endl;
    } else if (YYMM == false && MMYY == true) {
        cout << "YYMM" << endl;
    } else if (YYMM == false && MMYY == false) {
        cout << "AMBIGUOUS" << endl;
    }

}


Measured memory_bytes: 256