akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

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

	vector<int> p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	
	vector<int> p_sorted;
	p_sorted = p;
	sort(p_sorted.begin(), p_sorted.end());
	
	if (p == p_sorted) {
		cout << "YES" << endl;
		return 0;
	}

	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			vector<int> q;
			q = p;
			swap(q[i], q[j]);
			if (p_sorted == q) {
				cout << "YES" << endl;
				return 0;
			}
		}		
	}
	
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

#define ll long long

int main() {

    int n;
    ll t, minn, maxx, difmax = 0, a, nr = 0;
    scanf("%d%lld", &n, &t);
    scanf("%lld", &maxx);
    minn = maxx;
    for (int i = 2; i <= n; i++) {
        scanf("%lld", &a);
        if (a > maxx)
            maxx = a;
        if (a < minn) {
            if (difmax < maxx - minn) {
                difmax = maxx - minn;
                nr = 1;
            } else if (difmax == maxx - minn)
                nr++;
            minn = a;
            maxx = a;
        }
    }
    if (difmax < maxx - minn) {
        difmax = maxx - minn;
        nr = 1;
    } else if (difmax == maxx - minn)
        nr++;
    printf("%lld", nr);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>//author::@whohet-->Het Patel
#define fasterthanlight ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define test int T; cin>>T; while(T--)
#define endl "\n"
#define int long long
#define vi vector<int>
#define pb push_back
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
using namespace std;

//author::@whohet-->Het Patel

signed main()
{
	fasterthanlight;
	int r, d, x;
	cin >> r >> d >> x;
	int t = 1;
	while (t <= 10)
	{
		cout << (r * x) - d;
		x = r * x - d;
		t++;
		cout << endl;
	}
	return 0;
}


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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	int n;
	cin >> n;
	vector<int> a1;
	vector<int> a2;
	vector<int> s1(n, 0);
	vector<int> s2(n, 0);

	for(int i=0; i<n; i++){
		int tmp;
		cin >> tmp;
		a1.push_back(tmp);
	}
	for(int i=0; i<n; i++){
		int tmp;
		cin >> tmp;
		a2.push_back(tmp);
	}

	for(int i=1; i<n; i++){
		if(a1[i] == a1[i-1]){
			s1[i] = 1;
		}
	}
	for(int i=n-2; i>=0; i--){
		if(a2[i] == a2[i+1]){
			s2[i] = 1;
		}
	}

	for(int i=0; i<n; i++){
		if(s1[i] == 0 && a1[i] > a2[i]){
			puts("0");
			return 0;
		}
		if(s2[i] == 0 && a2[i] > a1[i]){
			puts("0");
			return 0;
		}
	}

	/*
	for(int i=0; i<n; i++){
		printf("%d ", s1[i]);
	}
	puts("");
	for(int i=0; i<n; i++){
		printf("%d ", s2[i]);
	}
	puts("");
	*/

	long long ans = 1;
	for(int i=0; i<n; i++){
		long long x;
		if(s1[i] == 1 && s2[i] == 1){
			x = min(a1[i], a2[i]);
			//cout << x << endl;

			ans = (ans * x) % MOD;
			//cout << ans << endl;
		}
	}

	if(a1[n-1] != a2[0]) ans = 0;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2168
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
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;}

int main() {
    int n,T;
    cin >> n >> T;
    int si = 0;
    int now = 0;
    int ans = 0;
    bool ok = false;
    rep(i,n) {
        int t;
        cin >> t;
        if(i==0) {
            now += T;
            continue;
        }
        if(now>=t) now = t+T;
        else {
            ans += now - si;
            si = t;
            now = t+T;
        }
    }
    ans += now-si;
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;

//素数判定
inline bool IsPrime(int p) {
	if (p == 1) return false;
	for (int i = 2; i <= sqrt(p); i++) {
		if (p%i == 0) return false;
	}
	return true;
}

//10進数の自然数の桁数を返す
inline int GetDigit(int num) {
	return (int)log10(num) + 1;
}

//各位の和を返す
int GetDigitsSum(int num) {
	int N = 0;
	while (num > 0) {
		N += num % 10;
		num /= 10;
	}
	return N;
}



//異なるn個からr個の整数を取り出す組合せの数を求める
int combination(int n, int r) {
	if (r == 0 || n == r) {
		return 1;
	}
	else if (r == 1) {
		return n;
	}
	else {
		return combination(n - 1, r - 1) + combination(n - 1, r);
	}

}

struct MyStruct
{
	int x;
	int no;
	int P;
	int Y;
};

struct city
{
	vector<MyStruct> M;

};

struct ans
{
	int P;
	int x;
	int no;
};

bool cmp(const ans &a, const ans &b)
{
	return a.no < b.no;
}

bool cmpY(const MyStruct &a, const MyStruct &b) {
	return a.Y < b.Y;
}

int main() {
	int N, M;

	vector<city> c(100001);
	vector<ans> AAA;

	cin >> N >> M;
	for (int i = 0; i < M; i++)
	{
		MyStruct tmp;
		cin >> tmp.P >> tmp.Y;
		tmp.no = i;
		c[tmp.P].M.push_back(tmp);
	}

	for (int i = 0; i < 100001; i++)
	{
		sort(c[i].M.begin(), c[i].M.end(),cmpY);
		int n = (int)c[i].M.size();
		int dtx = 1;
		for (int j = 0; j < n; j++)
		{
			c[i].M[j].x = dtx++;
		}

		for (int j = 0; j < n; j++)
		{
			ans A;
			A.no = c[i].M[j].no;
			A.P = c[i].M[j].P;
			A.x = c[i].M[j].x;
			AAA.push_back(A);
		}
	}

	sort(AAA.begin(), AAA.end(), cmp);
	for (int i = 0; i < M; i++)
	{
		printf("%06d%06d\n", AAA[i].P, AAA[i].x);
	}

	return 0;
}


Measured memory_bytes: 8308
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    float suti = scan.nextInt();
    float suti2 = suti;
    int wa = 0;
    while(suti != 0){
      wa = wa + (int)(suti % 10);
      suti = suti / 10;
    }
    if (suti2 % wa == 0) {
      System.out.println("Yes");
    }else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 23764
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<climits>

/*
#include<boost/multiprecision/cpp_long long.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Blong long = mp::cpp_long long;
*/

using namespace std;

#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

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

    long long ac=0;
    long long ans=0;
    for(long long i=0;i<(long long)s.size()-2;i++){
        if(s[i]=='A') ac++;
        else ac=0;
        if(s.substr(i,3)=="ABC"){
            ans+=ac;
            ac--;
            i++;
            s[i+1]='A';
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3476
n,a=int(input()),[sorted(list(map(int,input().split())))for i in range(3)]
b=[[],[]]
x=0
for i in range(n):
  while a[2][i]>a[1][x]:
    b[1].append(n-i)
    x+=1
    if x==n:break
  if x==n:break
for i in range(n-len(b[1])):b[1].append(0)
for i in range(1,n):b[1][n-i-1]+=b[1][n-i]
x=0
for i in range(n):
  while a[1][i]>a[0][x]:
    b[0].append(b[1][i])
    x+=1
    if x==n:break
  if x==n:break
print(sum(b[0]))

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

class Program
{
    static void Swap(int[] A, int from, int to)
    {
        int temp = A[from];
        A[from] = A[to];
        A[to] = temp;
    }
    static int SelectionSort(int[] A)
    {
        int swapnum = 0;
        for (int i = 0; i < A.Length; i++)
        {
            int minidx = i;
            for (int j = i; j < A.Length; j++) minidx = (A[j] < A[minidx])? j: minidx;
            Swap(A, i, minidx);
            swapnum = (minidx != i)? swapnum + 1: swapnum;
        }
        return swapnum;
    }

    public static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        int[] A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        int res = SelectionSort(A);
        for (int i = 0; i < N - 1; i++) Console.Write("{0} ", A[i]);
        Console.WriteLine(A[N - 1]);
        Console.WriteLine(res);
    }
}


Measured memory_bytes: 20364
import sys
import math
p1=int(input())
p2=int(input())
p3=int(input())
j1=int(input())
j2=int(input())
p_min=min(p1,p2,p3)
J_min=min(j1,j2)
min_sum=p_min+J_min-50
print(min_sum)



Measured memory_bytes: 5648
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;


int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N;cin>>N;
    cout << N*800-(N/15)*200 << endl;
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    long long A[N];
    rep(i, N) cin >> A[i];

    int zero = 0;
    rep(i, N) if (A[i] == 0) zero++;

    if (zero > 0) {
        cout << 0 << endl; 
        return 0;
    }
    

    long long prod = 1;
    rep(i, N) {
        if (A[i] <= 1000000000000000000 / prod) {
            prod *= A[i];
        } else {
            cout << -1 << endl; 
            return 0;
        }
    }

    cout << prod << endl;

    return 0;
}

Measured memory_bytes: 4392
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<iomanip>
#include<cstring>
#include<queue>
#include<stack>
using namespace std;

#define mod 1000000007
#define fr(i,n) for(int i=0;i<n;i++)
#define frn(i,n) for(int i=n-1;i>=0;i--)
#define fr1(i,n) for(ll i=1;i<=n;i++)
#define frn1(i,n) for(int i=n;i>0;i--)
#define N 100002
#define ll long long
#define mid(a,b) a+(b-a)/2


void solve(){
    int d,t,s;
    cin>>d>>t>>s;
    if(s*t>=d) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


int main(){
    ios_base::sync_with_stdio(false);   
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    t=1;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef pair<ul, ul> P;

const int INF = 1e9;
const int MOD =1e9+7;
const ll LINF = 1e18;

int main(){
    int N;
    int H[110000];

    cin >> N;
    rep(i,N) cin >> H[i];

    int border = 0;
    rep(i,N - 1){
        long sub = H[i + 1] - H[i];

        if(sub <= -2 || border > H[i + 1]) {
            cout << "No" << endl;
            return 0;
        }

        if(H[i] > border) border = H[i] - 1;
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 640
n = int(input())
h = list(map(int, input().split()))

v = 1
flag = True
for i in range(n):
    if v < h[i]:
        v = h[i] - 1
    elif v == h[i]:
        pass
    else:
        flag = False
        break

if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 64208
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static int ans = 0;
    static final int MOD = (int)1e9 + 7;
    public static void main(String[] args) {
        int H = sc.nextInt(), W = sc.nextInt();
        char[][] maze = new char[H + 1][W + 1];
        int[][] f = new int[H + 1][W + 1];
        f[1][1] = 1;
        for(int i = 1; i <= H; i ++){
            String s = sc.next();
            for(int j = 1; j <= W; j ++){
                maze[i][j] = s.charAt(j - 1);
            }
        }
        for(int i = 1; i <= H; i ++){
            for(int j = 1; j <= W; j ++){
                if(i == 1 && j == 1)continue;
                if(maze[i][j] == '.')f[i][j] = (f[i - 1][j] + f[i][j - 1]) % MOD;
            }
        }
        System.out.println(f[H][W]);
    }
}

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

typedef long long LL;

const int N=100000,mod=1000000007;

int add(int a,int b,int p=mod){return a+b>=p?a+b-p:a+b;}
int sub(int a,int b,int p=mod){return a-b<0?a-b+p:a-b;}
int mul(int a,int b,int p=mod){return (LL)a*b%p;}
void sadd(int &a,int b,int p=mod){a=add(a,b,p);}
void ssub(int &a,int b,int p=mod){a=sub(a,b,p);}
void smul(int &a,int b,int p=mod){a=mul(a,b,p);}

int n,m,a[N+9],b[N+9];

void into(){
  scanf("%d%d",&n,&m);
  for (int i=1;i<=n;++i)
	scanf("%d",&a[i]);
  for (int i=1;i<=m;++i)
	scanf("%d",&b[i]);
}

struct point{
  int x,y;
  point(int X=0,int Y=0){x=X;y=Y;}
  bool operator == (const point &p)const{return x==p.x&&y==p.y;}
}d[N+9];
int ord[N+9];

bool cmp(const point &a,const point &b){return a.x<b.x||a.x==b.x&&a.y>b.y;}

void Get_xy(){
  sort(b+1,b+m+1);
  int lst=0;
  for (int i=1;i<=n;++i){
	if (a[i]<=b[1]||a[i]>=b[m]) continue;
	int t=lower_bound(b+1,b+m+1,a[i])-b;
	if (a[i]==b[t]) continue;
	d[++lst]=point(a[i]-b[t-1],b[t]-a[i]);
  }
  n=lst;
  for (int i=1;i<=n;++i) ord[i]=d[i].x;
  sort(ord+1,ord+n+1);
  for (int i=1;i<=n;++i) d[i].x=lower_bound(ord+1,ord+n+1,d[i].x)-ord;
  for (int i=1;i<=n;++i) ord[i]=d[i].y;
  sort(ord+1,ord+n+1);
  for (int i=1;i<=n;++i) d[i].y=lower_bound(ord+1,ord+n+1,d[i].y)-ord;
  sort(d+1,d+n+1,cmp);
  n=unique(d+1,d+n+1)-d-1;
}

int c[N+9];

void Add(int p,int v){for (;p<=N;p+=p&-p) sadd(c[p],v);}
int Query(int p){int res=0;for (;p;p-=p&-p) sadd(res,c[p]);return res;}

int dp[N+9],ans;

void Get_dp(){
  for (int i=1;i<=n;++i){
	sadd(ans,dp[i]=add(Query(d[i].y-1),1));
	Add(d[i].y,dp[i]);
  }
}

void work(){
  Get_xy();
  Get_dp();
}

void outo(){
  printf("%d\n",add(ans,1));
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 2944
h, w, k = map(int, input().split())
m = []
for i in range(h):
    m.append(list(input()))

ans = []
for i in range(h):
    ans.append([0 for _ in range(w)])

if m[0][0] == '#':
    c = 0
else:
    c = 1
emp = []
for i in range(h):
    s1 = 0
    s = m[i].count('#')
    # 行に一つもいちごがない
    if s == 0:
        emp.append(i)
        continue
    for j in range(w):
        flag = 0
        if m[i][0] == '#':
            if m[i][j] == '#':
                if s1 < s and c < k:
                    s1 += 1
                    c += 1
            ans[i][j] = c
        else:
            ans[i][j] = c
            if m[i][j] == '#':
                flag = 1
                if s1 < s-1 and c < k:
                    s1 += 1
                    c += 1
    if i != h-1 and m[i+1][0] != '#':
        c += 1

if 0 in emp:
    for j in range(w):
        for i1 in range(1, h):
            if ans[i1][0] != 0:
                idx = ans[i1]
                break
        ans[0][j] = idx[j]
    emp.remove(0)
if h-1 in emp:
    for j in range(w):
        for i1 in list(range(h-1))[::-1]:
            if ans[i1][0] != 0:
                idx = ans[i1]
                break
        ans[h-1][j] = idx[j]
    emp.remove(h-1)
for e in emp:
    for j in range(w):
        idx = []
        for i1 in range(e+1, h):
            if ans[i1][0] != 0:
                idx = ans[i1]
                break
        ans[e][j] = idx[j]

for i in ans:
    print(' '.join(map(str, i)))


Measured memory_bytes: 47836
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <math.h>

using namespace std;

typedef long long ll;

string beautify(string str) {
	string ret = "";
	for (int i = 0; i < str.size(); ++i) {
		char c = str[i];
		if ('a' <= c && c <= 'z') ret += c;
		else if ('A' <= c && c <= 'Z') ret += (char)(c-'A'+'a');
	}
	return ret;
}

int main() {
	double x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
	double dx = x2 - x1, dy = y2 - y1;
	printf("%.10f\n", sqrt(dx*dx + dy*dy));
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std; 
int main(){
  int N;
  cin >> N;
  int mons; 
  queue<pair<int,int> > monsters; 
  int hero;
  queue<pair<int,int> > heroes; 
  long long total = 0; 
  for (int i = 0; i <= N; i++){
    cin >> mons;
    monsters.push(make_pair(mons,i)); 
  }
  for (int i = 0; i < N; i++){
    cin >> hero;
    heroes.push(make_pair(hero,i)); 
  }
  while(monsters.size() > 0 && heroes.size() > 0){
    if (monsters.front().second - heroes.front().second < 0){
      monsters.pop(); 
    } else if (monsters.front().second - heroes.front().second > 1){
      heroes.pop(); 
    } else {
    int enemy = monsters.front().first;
    int saviour = heroes.front().first; 
    if (enemy > saviour){
      monsters.front().first -= saviour; 
      total += saviour; 
      heroes.pop(); 
    } else if (enemy == saviour) {
      total += saviour; 
      monsters.pop(); 
      heroes.pop(); 
    } else {
      heroes.front().first -= enemy; 
      total += enemy;
      monsters.pop(); 
    }
    }
  }
  cout << total; 
}

Measured memory_bytes: 1920
s = gets.chomp
t = gets.chomp

s_len = s.length
t_len = t.length
arr = []
s.length.times do |i|
  w = s.dup
  w[i..i+t_len-1] = t
  next if w.length > s_len
  flag = true
  s_len.times do |j|
    if s[j] != '?'
      flag = false unless w[j] == s[j]
    end
  end
  #puts w if flag
  if flag
    w.gsub!('?','a')
    arr.push(w)
  end
end;

if arr.length > 0
  arr.sort!
  puts arr.first
else
  puts 'UNRESTORABLE'
end

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

using ll=long long; 

void solve(){
	int n;
	cin>>n;
	vector<int>p(n);
	for(int i=0; i<n; i++)cin>>p[i];
	int sum=accumulate(p.begin(), p.end(), 0);
	sum-=*(max_element(p.begin(), p.end()))/2;	
	cout<<sum<<endl;
}

signed main(){
	//while(1)
	solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define PI          acos(-1)
#define INF         100000000
#define sc(n)       scanf("%d",&n);
#define ssc(n)      scanf("%s",n);
#define lsc(n)      scanf("%lld",&n);
#define dsc(n)      scanf("%lf",&n);
#define csc(n)       scanf("%c",&n);
#define LL          long long int
#define UI          unsigned int
#define ULL         unsigned long long int
#define DB          double
#define pii         pair<int,int>
#define VI          vector<int>
#define MII         map<int,int>
#define PB          push_back
#define MP          make_pair
#define M(mx,a)     mx=max(mx,a)
#define IT          ::iterator
#define all(a)      a.begin(),a.end()
#define mems(a,b)   memset(a,b,sizeof(a))
#define F(i,a,b)    for(i=a;i<b;i++)
#define IN(n,aa)    for(i=0;i<n;i++)scanf("%d",&aa[i]);
#define PNT(n,aa)   for(i=0;i<n;i++)printf("%lld ",aa[i]);
#define mod         1000000007
#define NUM         2009
#define NUM2        1000000000


LL dd[NUM][NUM];

int main()
{
    int T=1,QQ=0;
    //cin >> T ;
    while(T--)
    {
        int n,m,i,j,k,sm=0;
        sc(n);sc(m);
        int aa[n],bb[m];
        for(i=1;i<=n;i++)sc(aa[i]);
        for(i=1;i<=m;i++)sc(bb[i]);
        mems(dd,0);
        for(i=1;i<=n;i++)
        {
            sm=0;
            for(j=1;j<=m;j++)
            {
                sm+=dd[i-1][j];
                sm%=mod;
                if(aa[i]==bb[j])
                {
                    dd[i][j]=sm+1;
                    dd[i][j]%=mod;
                }
                else
                {
                    dd[i][j]=dd[i-1][j];
                }
            }
        }
        LL ans=0;
        for(i=1;i<=m;i++)
            ans+=dd[n][i],ans%=mod;
        cout << ans+1 ;
    }
}

//printf("Case %d: ",++QQ);


Measured memory_bytes: 35272
s = str(input())
n = len(s) - 1
sum = ''
for i in range(1 << n):
    for j in range(len(s)):
        if i & 1 << j:
            sum += str(s[j])
        else:
            sum += str(s[j]) + '+'
sum = sum.rstrip('+')
print(eval(sum))


Measured memory_bytes: 4136
s = input()
res = 0
n = len(s)
cnt = 0
for i in range(n):
    if i % 2 == 0:
        if s[i] == "0":
            cnt += 1
    else:
        if s[i] == "1":
            cnt += 1
res = n - cnt
cnt = 0
for i in range(n):
    if i % 2:
        if s[i] == "0":
            cnt += 1
    else:
        if s[i] == "1":
            cnt += 1
res = min(res, n - cnt)
print(res)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
    #include <chrono>
    using namespace std;
    typedef long long ll;
    #define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
    #define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
    #define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
    #define ill(_x)  ll _x;scanf("%lld",&_x);
    #define idb(_x)  double _x;scanf("%lf",&_x);
    #define all(x) (x).begin(),(x).end()
    #define pll pair<ll,ll>
    #define mll map<ll,ll>
    #define vll vector<ll>
    #define sll set<ll>
    #define vs vector<string>
    #define in0(x, a, b)((x)>=a && (x)<=b    )
    #define in1(x, a, b)((x)>a && (x)<b)
    #define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
    const double pi = 3.14159265358979323846;
    const int INF = 0x3f3f3f3f;
    const int X10=1024,X11=2048,X12=4096,X13=8196,X14=16392,X15=32786,X16=65536,X17=131072,X18=262144,X19=524288,X20=1048576;


    void _ (){
        double n,m,d;
        cin >> n >> m >> d;
        if(round(n)==round(2*d )|| round(d)==0)cout << setprecision(14)<<(m-1)*1./n;
        else cout << setprecision(14)<<(m-1)*1.*(2*n-2*d)/n/n;

    }


    int main() {
    #ifdef Debug
        freopen("/home/joduskame/Desktop/cpp/IO/Input.txt", "r", stdin);
        freopen("/home/joduskame/Desktop/cpp/IO/Output.txt", "w", stdout);
    #endif
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        _();
        return 0;

    }








Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

long long n, m, ans;

int main() {
  cin>>n>>m;
  if(n == 1) {
    if(m == 1) ans = 1;
    else ans = m - 2;
  }
  if(m == 1) {
    if(n == 1) ans = 1;
    else ans = n - 2;
  }
  if(m > 1 && n > 1) {
    ans = (m - 2) * (n - 2);
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int N;
  cin >> N;
  vector<double> v(N);
  for(int i = 0; i < N; i++){
    cin >> v[i];
  }

  sort(v.begin(), v.end());

  double tmp = 0;
  for(int i = 0; i < N-1; i++){
    tmp = (v[i] + v[i+1]) / 2.0;
    v[i+1] = tmp;
  }

  cout << setprecision(15) << v[N-1] << endl;


  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
bool ok[9][9] = {};
void check(int *a, int x, bool f) {
	int c[9] = {};
	rep(i,9) c[a[i]-1]++;
	rep(i,9) {
		if(c[a[i]-1] != 1) {
			if(f) ok[x][i] = 1;
			else ok[i][x] = 1;
		}
	}
}
int main() {
	int n;
	cin >> n;
	bool p = 0;
	while(n--) {
		if(p) cout << endl;
		p = 1;
		int b[9][9];
		rep(i,9) {
			rep(j,9) {
				ok[i][j] = 0;
				cin >> b[i][j];
			}
		}
		rep(i,9) {
			int a[9];
			rep(j,9) {
				a[j] = b[i][j];
			}
			check(a,i,1);	
		}
		rep(i,9) {
			int a[9];
			rep(j,9) {
				a[j] = b[j][i];
			}
			check(a,i,0);	
		}
		rep(w,9) {
			if(w%3!=0) continue;
			rep(h,9) {
				if(h%3!=0) continue;
				int c[9]={};
				rep(i,3) {
					rep(j,3) {
						c[b[w+i][h+j]-1]++;
					}
				}
				rep(i,3) {
					rep(j,3) {
						if(c[b[w+i][h+j]-1] != 1) ok[w+i][h+j] = 1;
					}
				}
			}
		}
		rep(i,9) {
			string ret;
			rep(j,9) {
				if(ok[i][j]) ret += '*';
				else ret += ' ';
				ret += (char)(b[i][j]+'0');
			}
			cout << ret << endl;
		}
	}
	return 0;
}

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

const int MAXN = 100005;
const int MAXM = 100005;
typedef unsigned long long ull;
const ull bas = 19260817;

int prime[10000], top = 0;
int not_prime[MAXN];

void get_prime(int n)
{
	for (int i = 2; i <= n; i++) {
		if (!not_prime[i]) prime[++top] = i;
		for (int j = 1; j <= top && prime[j]*i <= n; j++) {
			not_prime[i*prime[j]] = 1;
			if (i%prime[j] == 0)
				break;
		}
	}
}

int n;
long long a[MAXN];
int powd[MAXN];
const int S = 1911589;

struct node {
	long long to;
	int next;
	int id;
} edge[MAXN*2];
int head[S], tot = 0;
inline void push(long long val, int id)
{
	int to = val%S;
	edge[++tot] = (node) {val, head[to], id}, head[to] = tot;
}
inline void visit(long long val, int x)
{
	int nd = val%S;
	for (register int i = head[nd]; i; i = edge[i].next) {
		long long to = edge[i].to;
		int id = edge[i].id;
		if (to == val) {
			powd[id] = max(powd[id], x);
		}
	}
}
map<pair<long long, long long>, int> stx, sty;

int main()
{
	get_prime(MAXM-1);
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		powd[i] = 1;
		for (int j = 1; j <= top; j++) {
			long long cur = (long long)prime[j]*prime[j]*prime[j];
			if (cur > a[i]) break;
			while (a[i]%cur == 0)
				a[i] /= cur;
		}
		push(a[i], i);
	}
	int B = 1300;
	for (register int i = 1; i <= B; i++)
		for (register int j = 1; j <= n; j++)
			if (a[j] % (i*i) == 0) 
				powd[j] = max(powd[j], i);
	for (register int i = B+1; i <= 100000; i++) {
		long long v = (long long)i*i;
		for (register long long j = v; j <= 10000000000ll; j += v)
			visit(j, i);
	}
	int cnt = 0;
	for (register int i = 1; i <= n; i++) {
		if (a[i] == 1) cnt = 1;
		else {
			auto v = make_pair(a[i]/powd[i]/powd[i], powd[i]);
			if (v.first < v.second) 
				stx[v]++;
			else {
				sty[v]++;
				if (!stx.count(make_pair(v.second, v.first)))
					stx[make_pair(v.second, v.first)] = 0;
			}
		}
	}
	for (register auto j : stx)
		cnt += max(j.second, sty[make_pair(j.first.second, j.first.first)]);
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 24576
#include "stdio.h"

int main(){
  int x,y,ans=0;
  scanf("%d %d",&x,&y);
  if(x==1) ans+=300000;
  if(x==2) ans+=200000;
  if(x==3) ans+=100000;
  
  if(y==1) ans+=300000;
  if(y==2) ans+=200000;
  if(y==3) ans+=100000;
  
  if(x==1 && y==1) ans+=400000;
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 128
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int s;
    scan(s);

    int ans = 1;

    bool[long] e;

    long f(long x) {
        if (x & 1) {
            return 3 * x + 1;
        }
        else {
            return x / 2;
        }
    }

    long a = s;
    e[s] = true;

    while (true) {
        ans++;
        a = f(a);
        if (a in e) {
            writeln(ans);
            return;
        }
        e[a] = true;
    }
}





void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;
typedef pair<int, int>             pii;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

const int N = 2e5 + 5;

ll A[N], pre[N];

int main(){
    fIO

    int n, k;
    cin >> n >> k;

    for(int i = 0; i < n; i++) {
        cin >> A[i];
        A[i] %= k;
    }

    for(int i = 1; i <= n; i++) {
        pre[i] = pre[i - 1] + A[i - 1];
    }

    for(int i = 1; i <= n; i++) {
        pre[i] = ((pre[i] - i) % k + k) % k;
    }

    map<ll, int> mp;
    mp[0LL] = 1;

    ll ans = 0;

    for(int i = 1; i <= n; i++) {
        if(i - k >= 0) {
            mp[pre[i - k]] += -1;
        }

        ans += (ll) mp[pre[i]];
        mp[pre[i]] += 1;
    }
    cout << ans;
}












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

int main(){
  int n, m;
  int c = 0;
  int sum = 0;
  int i;
  float vote;
  
  cin >> n >> m;
  int a[n];
  for(i = 0; i < n; i++){
  	cin >> a[i];
  }
  for(i = 0; i < n; i++){
  	sum += a[i];
  }
  for(i = 0; i < n; i++){
  	if(a[i] * (4 * m) >= sum){
      c++;
    }
  }
  if(c >= m)
    cout << "Yes" << endl;
  else
    cout << "No" << endl; 
  return 0;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
#define two(a) (1<<(a))
#define LINF (1ll<<61)
#define EPS (1e-14)
#define Lshift(a,b) ((a)<<(b))
#define Rshift(a,b) ((a)>>(b))
#define rep(a,b) for(a=0 ; a<b ; a++)
#define xrep(a,b,c) for(a=b ; a<c ; a++)
#define INF (1<<29)
#define sz(a) int(a.size())
#define swap(a,b) ( (a^=b) , (b^=a) , (a^=b) )
#define GET(x) (mark[x>>5]>>(x&31)&1)
#define SET(x) (mark[x>>5]|=1<<(x&31))
#define maxL (10000000>>5)+1
#define mod 1000000007
#define vi vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>
#define pb push_back
typedef long long ll;
using namespace std;


int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    ll i, n;
    cin >> n;
    ll ans(0);
    xrep(i, 1, n + 1) {
        if (i % 3 != 0 && i % 5 != 0) ans += i;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3640
# -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))
N = input()

res = 0
for i, j in enumerate(N):
    if j != "9":
        break

if i >= 2:
    res += 9*(i-1)
    N = N[i-1:]

A = 10**(len(N)-1)

res += max(sum(map(int, N)), sum(map(int, str(int(N)//A*A-1))))
print(res)

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


int main() {
	// your code goes here
	int n,arr[1000];
	cin>>n;
	for(int i=1;i<=n;++i)
	cin>>arr[i];
	int pref[1000];
	pref[0]=0;
	for(int i=1;i<=n;++i)
	pref[i]=pref[i-1]+arr[i];
	int min=32000;
	for(int i=1;i<=n;++i)
	{
	    if(abs(pref[n]-2*pref[i])<min)
	        min=abs(pref[n]-2*pref[i]);
	}
	cout<<min<<endl;
	return 0;
}


Measured memory_bytes: 256
/**
 *  author: andychen
 *  created: 09.13.2020 19:59:40
**/

#include <bits/stdc++.h>

using namespace std;

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

    cout << (x ^ 1) << '\n';

    return 0;
}


Measured memory_bytes: 3644
n = io.read("*n", "*l")
s = io.read()
B, R = 0, 0
for i = 1, n do
  if(string.sub(s, i, i) == "B") then B = B + 1 else R = R + 1 end
end
if(B < R) then print("Yes") else print("No") end

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n,i,j;
  string s="Yes";
  cin>>n;
  vector<int> h(n);
  for(i=0;i<n;i++) cin>>h.at(i);
  for(i=0;i<n-1;i++){
    if(h.at(i+1)-h.at(i)<-1) {s="No"; break;}
    else if(h.at(i+1)-h.at(i)==-1 && i<n-2){
      for(j=i+2;j<n;j++){
        if(h.at(j)<h.at(i+1)) {s="No"; break;}
        else if(h.at(j)>=h.at(i)) break;
      }
      if(j==n || s=="No") break;
      else i=j-1;
    }
  }
  cout<<s<<endl;
}

Measured memory_bytes: 640
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 3005;
template <class T> void chmax(T& a, T b){ a = max(a, b);};
//
//
int r, c;
ll g[MAX][MAX];
ll dp[MAX][MAX][4]; // 0 1 2 3

void solve(){
    cin>>r>>c;
    int k;
    cin>>k;
    memset(g, 0, sizeof(g));
    memset(dp, 0, sizeof(dp));
    for(int i = 0; i < k; i++){
        int x, y, val;
        cin>>x>>y>>val;
        g[x][y] = val;
    }

    // dp[1][1][0]= 0;
    for(int i = 1; i <= r; i++)
        for(int j = 1; j <= c; j++){
            for(int k = 2; k >= 0; k--){
                chmax(dp[i][j][k+1], dp[i][j][k]+g[i][j]);
            }
            for(int k = 0; k <= 3; k++){
                chmax(dp[i][j+1][k], dp[i][j][k]);
                chmax(dp[i+1][j][0], dp[i][j][k]);
            }
        }
    ll ans = 0;
    for(int i = 0; i <= 3; i++)
        chmax(ans, dp[r][c][i]);
    cout<<ans<<"\n";
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

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

using namespace std;

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

    cin >> a >> b;

    if (a % 2 == 0 || b % 2 == 0) {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
#define showm(m) for(auto i: m){cout << m.x << " ";}
typedef long long ll;
typedef pair<int, int> P;


int main()
{
    ll w, h, x, y;
    cin >> w >> h >> x >> y;

    double ans1 = (double)(w * h) / 2.0; 
    int ans2 = 0; 
    if (x == (w/2) && y == (h/2) && w%2 == 0 && h%2 == 0){
        ans2 = 1;
    }
    cout << ans1 << " " << ans2 << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf 0x7fffffff
#define ll long long
#define REP(i,a,b) for(int i=a;i<=b;i++)
using namespace std;

int main() {
        ios_base::sync_with_stdio(false); 
        cin.tie(NULL);
        // Code Starts...
        ll n,k;
        cin>>n>>k;
        vector<ll > v(n);
        for (int i=0;i<n;i++)
            cin>>v[i];
        vector<ll > dp(n+1,inf); // it stores the min cost incurred so far...
        dp[0] = 0; // cost at stone 1 is 0...
  		dp[1] = abs(v[1] - v[0]); // cost for stone 1...
        // Now what matters so far i.e. at ith stone 
  		// 1. from where i had jumped from...
  		// 2. cost so far stored in dp[i]...that is of course minimum...
  		for (int i=2;i<n;i++)
  		    for (int j=1;j<=k;j++)
                {
                    if (i>=j)
                        dp[i] = min(dp[i] , dp[i-j] + abs(v[i]-v[i-j]));
                }
        cout<<dp[n-1]<<endl;
        // Code Ends...
        return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <vector>

using namespace std;

const int N = 200'009;

int a[N];
bool vis[N];

int main() {
  int n;
  long long m;
  scanf("%d%lld", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
    --a[i];
  }
  for (int i = 0; i < n; ++i) {
    vis[i] = false;
  }
  int cnt = 0;
  int x = 0;
  while (cnt < m) {
    vis[x] = true;
    x = a[x];
    ++cnt;
    if (vis[x]) {
      break;
    }
  }
  for (int i = 0; i < n; ++i) {
    vis[i] = false;
  }
  vector<int> w;
  int y = x;
  while (true) {
    vis[y] = true;
    w.push_back(y);
    y = a[y];
    if (vis[y]) {
      break;
    }
  }
  printf("%d\n", w[(int)((m - cnt) % (int)w.size())] + 1);
}


Measured memory_bytes: 4716
import sys

N,K = map(int,input().split())

a = list(map(int,input().split()))

a2 = []

for i in range(N):
    a2.append([a[i],i+1])

ans = []
mind = 0

for i in range(K+1):

    a2.sort()
    a2.reverse()

    omind = mind

    if i == 0:
        for j in range(N):
            a2[j][0] -= 1
            ans.append(a2[j][1])

            if a2[j][0] < 0:
                print (-1)
                sys.exit()

        mind = a2[-1][1]

    else:

        for j in range(N):

            if a2[j][1] != mind:

                a2[j][0] -= 1
                ans.append(a2[j][1])

            if a2[j][0] < 0:
                print (-1)
                sys.exit()

        a2.sort()
        a2.reverse()
        if mind == a2[-1][1]:
            mind = a2[-2][1]
        else:
            mind = a2[-1][1]

print (len(ans))
print (" ".join(map(str,ans)))


Measured memory_bytes: 3188
#include<stdio.h>
int a[100] = {0};

int main(){

    

    int n;
    scanf("%d",&n);

    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }

 for(int k=0;k<n;k++){
            if(k==n-1)
            printf("%d\n",a[k] );
            else
            printf("%d ",a[k]);
        }

    for(int i=1;i<n;i++){
       
       
        int key = a[i];

        int j = i-1;
        while(j>=0 && a[j]>key){
            a[j+1] = a[j];
            j--;
             a[j+1] = key;
            
        } 
          
         for(int k=0;k<n;k++){
            if(k==n-1)
            printf("%d\n",a[k] );
            else
            printf("%d ",a[k]);
            
        }
         
        
    }


    

    return 0;
}


Measured memory_bytes: 2112
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

const int MOD = 1e9 + 7;

int main() {
    int n, m;
    cin >> n >> m;
    vector<ll> s(n), t(m);
    REP(i, n) {
        cin >> s[i];
    }
    REP(i, m) {
        cin >> t[i];
    }

    vector<vector<ll>> dp(n+1, vector<ll>(m+1, 0));
    IFOR(i, 0, n){
        dp[i][0] = 1;
    }
    IFOR(i, 0, m){
        dp[0][i] = 1;
    }

    IFOR(i, 1, n){
        map<int, ll> accum;
        IFOR(j, 1, m){
            dp[i][j] = dp[i-1][j];
            accum[t[j-1]] = (accum[t[j-1]] + dp[i-1][j-1]) % MOD;
            dp[i][j] = (dp[i][j] + accum[s[i-1]]) % MOD;

            
        }
    }

    cout << dp[n][m] << endl;
    return 0;
}

Measured memory_bytes: 31744
n=int(input())
d=list(map(int,input().split()))
error=0

if d[0]!=0:
	print(0)
else:
	d.sort()
	kotae=1
	kosulist=[]
	kazoe=1
	for i in range(1,n):
		if d[i]==d[i-1]:
			kazoe+=1
		else:
			kosulist.append(kazoe)
			kazoe=1
	kosulist.append(kazoe)
	
	kosukai=[1]
	for i in range(len(kosulist)-1):
		kosukai.append(kosukai[i]+kosulist[i+1])
	for i,a in enumerate(kosukai):
		if d[a-1]!=i:
			error=1
			break
			
	if error==0:		
		for i in range(len(kosulist)-1):
			kotae=kotae*((kosulist[i]**kosulist[i+1])%998244353)
		kotae=kotae%998244353
		print(int(kotae))
	else:
		print(0)

Measured memory_bytes: 14396
#include <bits/stdc++.h>
using namespace std;
#define ll  long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define pp pop_back
#define in insert
#define ff first
#define ss second
#define e endl
#define debug cout<<"we are debuuging"<<endl;
#define MOD 998244353
ll fast_expo(ll x,ll p)
{if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
int main()
{
     int n;
     cin>>n;
     ll a[n];
     ll maxi=1000000000000000000;
     for(int i=0;i<n;i++)
          cin>>a[i];
     ll p=1;
     sort(a,a+n);
     if(a[0]==0)
          {cout<<0;
     return 0;}
     for(int i=0;i<n;i++)
     {
          if((maxi/p)>=a[i])
          p=p*a[i];
          else
          {
               p=-1;
               break;
          }
     }
     cout<<p;
}


Measured memory_bytes: 4384
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<stdbool.h>
#include<math.h>
#include<time.h>
#define ll long long
#define min(a,b) ((a)>(b)?(b):(a))
#define max(a,b) ((a)>(b)?(a):(b))
#define miin(a,b,c) min((a), min((b), (c)))
#define maax(a,b,c) max((a), max((b), (c)))
int n, k;
double p[222222];
int main(){
    scanf("%d%d", &n, &k);
    for(int i = 0; i < n; i++){
        scanf("%lf", &p[i]);
        p[i] = (p[i] + 1) / 2;
    }
    double nyan = 0;
    for(int i=0;i<k;i++)nyan += p[i];
    double nyaa = nyan;
    for(int i=1;i+k <= n;i++){
        nyan -= p[i-1];
        nyan += p[i+k-1];
        nyaa = max(nyan, nyaa);
    }
    printf("%f\n",nyaa);
    return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
bool first_C=true;//是否为第一个C
bool first_F=true;//是否为第一个F
int C_POS=-1;
int rp;
char command[10000];
int main()
{
    gets(command);
    for(int i=0;i<strlen(command);i++)
    {
        if(command[i]=='C' && first_C)
        {
            rp++;
            first_C=!first_C;
            C_POS=i;
        }
        if(command[i]=='F' && first_F && i>C_POS && C_POS!=-1)
        {
            rp++;
            first_F=!first_F;
        }
        if(rp==2)
        {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}

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

int main(){
  
  int N;
  cin >> N;
  vector<int> h(N);
  for(int i=0;i<N;i++){
    cin >> h[i];
  }
  
  vector<int> dp(N,10000);
  dp[0] = 0;
  dp[1] = abs(h[1]-h[0]);
  
  for(int i=2;i<N;i++){
    int way1 = dp[i-1] + abs(h[i]-h[i-1]);
    int way2 = dp[i-2] + abs(h[i]-h[i-2]);
    dp[i] = min(way1,way2);
  }
  
  cout << dp[N-1] << endl;
}

Measured memory_bytes: 1024
// --------------
// Tejas Pandey  |
// 21 - 06 - 19  |
// Atcoder #131  |    |
// --------------

#include <bits/stdc++.h>
using namespace std;

#define mod 1000000007
typedef long long int ll;
ll gcd (ll a, ll b)
{
	if(a%b)
	return gcd(b,a%b);
	else
	return b;
}
int main (void)
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int n,k;
	cin >> n >> k;
	if(k > ((n-2)*(n-1))/2)
	{
		cout << "-1";
		return 0;
	}
	else
	{
		vector<pair<int,int>> ans;
		ans.push_back({1,2});
		for(int i = 3;i <=n;i++)
		{
			ans.push_back({2,i});
			k  -= i - 2;
			int f = 1;
			while( k < 0 )
			{
			if (f!=2)
			{
			ans.push_back({i,f});
			k++;
			}
			f++;
			}
		}
		cout << ans.size() << "\n";
		for(int i = 0;i < ans.size();i++)
		{
			cout << ans[i].first << " " << ans[i].second << "\n";
		}
	}
	return 0;
}

Measured memory_bytes: 384
s = input().split()[0]

# YYMMの可能性がある
format_list = []

if 1 <= int(s[:2]) <= 12:
    format_list.append('MMYY')

if 1 <= int(s[2:]) <= 12:
    format_list.append('YYMM')

if not format_list:
    ans = 'NA'
elif len(format_list) > 1:
    ans = 'AMBIGUOUS'
else:
    ans = format_list[0]

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP2(i, a, b) for(int i = a;i <= b;i++)
#define REPR(i, a, b) for(int i = a; i >= b; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define PI 3.14159265358979323846
#define vi vector<int>
#define vll vector<ll>
#define vi2 vector<vector<int>>
#define eb emplace_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
using P = pair<ll,ll>;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};
#define INT(name) int name;cin >> name;
#define VEC(type,name,n) vector<type> name(n);REP(i,n) cin >> name[i];

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

int main()
{
  ll N,Q;
  cin >> N >> Q;
  vector<P> A(Q);
  REP(i,Q){
    cin >> A[i].first >> A[i].second;
    A[i].se--;
  }
  ll H=N-2;
  ll W=N-2;
  ll cnt=0;
  vector<ll> vecw(N-1,N-2);
  vector<ll> vech(N-1,N-2);
  REP(i,Q){
    if(A[i].fi==1){
      if(A[i].se<=W){
        REP2(j,A[i].se+1,W){
          vecw[j]=H;
        }
        W=A[i].se-1;
        cnt+=H;
      }else{
        cnt+=vecw[A[i].se];
      }
    }else{
      if(A[i].se<=H){
        REP2(j,A[i].se+1,H){
          vech[j]=W;
        }
        H=A[i].se-1;
        cnt+=W;
      }else{
        cnt+=vech[A[i].se];
      }
    }
  }

  cout << (N-2)*(N-2)-cnt << endl;
}


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

int main(void) {
	string s;
	cin >> s;
	string ret = "Good";
	for (size_t i = 0; i < 3; i++){
		if (s[i] == s[i + 1]) {
			ret = "Bad";
			break;
		}
	}
	cout << ret << endl;
	return 0;
}

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

typedef long long int ll; 

int main(void)
{
	ll arr[5];
	ll ans=-1;
	for (ll i=0;i<5;i++)
	{
		cin >> arr[i];
		if(arr[i]==0)
			ans=i+1;
	}
	cout << ans << endl;



	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
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; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    ll K;
    cin >> K;

    if (K%2 == 0) {
        cout << -1 << endl;
        return 0;
    }

    // vector<pair<ll, ll>> pm = prime_factorize(7777);
    // for(auto i : pm) {
    //     cout << i.first << " " << i.second << endl;
        
    // }   
    // vector<pair<ll, ll>> pim = prime_factorize(77777);
    // for(auto i : pim) {
    //     cout << i.first << " " << i.second << endl;
        
    // }   
    
    
    ll num = 0;
    for(int i = 1; i <= K; i++) {
        num = num*10 + 7;
        num %= K;
        if (num == 0){
            cout << i << endl;
            return 0;
        }
    }


    cout << -1 << endl;
    

    return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pl= pair<ll,ll>;
using ld=long double;
using V=vector<int>;
using Vl=vector<ll>;
using VV=vector<vector<int>>;
using VVl=vector<vector<ll>>;

int main() {
    int n;cin >>n;
    int c=n;
    for (int i = 0; i < 2; ++i) {
        n*=c;
    }
    cout <<n<<endl;
}

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

const int mod = 1e9+7;
const int INF = 2000000;
const double PI = acos(-1.0);

int main() {
    int a,b;
    cin >> a >> b;
    cout << a*b << endl;
}


Measured memory_bytes: 3640