akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<ll> &v) {
    std::for_each(v.begin(), v.end(), [](ll x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N;
    cin >> N;
    vector<ll> A(N), B(N);
    REP(i, N) { cin >> A[i]; }
    REP(i, N) { cin >> B[i]; }
    //左端はT[0]できまる
    //右端はA[N-1]できまる
    if(A[N - 1] != B[0]) {
        cout << 0 << endl;
        return 0;
    }
    vector<ll> A_change(N, 0);
    A_change[0] = A[0];
    REP(i, N - 1) {
        if(A[i] != A[i + 1]) {
            A_change[i + 1] = A[i + 1];
        }
    }
    REP(i, N) {
        if(A_change[i] != 0) {
            if(B[i] < A_change[i]) {
                cout << 0 << endl;
                return 0;
            }
        }
    }
    vector<ll> B_change(N, 0);
    B_change[N - 1] = B[N - 1];
    for(int i = N - 1; i >= 1; i--) {
        if(B[i - 1] != B[i]) {
            B_change[i - 1] = B[i - 1];
        }
    }
    REP(i, N) {
        if(B_change[i] != 0) {
            if(A[i] < B_change[i]) {
                cout << 0 << endl;
                return 0;
            }
        }
    }
    // print(A_change);
    // print(B_change);
    ll ans = 1LL;
    REP(i, N) {
        if(A_change[i] != 0 and B_change[i] != 0) {
            if(A_change[i] != B_change[i]) {
                cout << 0 << endl;
                return 0;
            }
        }
        if(A_change[i] == 0 and B_change[i] == 0) {
            ans *= min(A[i], B[i]);
            ans %= MOD;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3328
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int t = 1; 
    // cin >> t; 
    while (t--) {
        string s, t;
        cin >> s >> t;

        bool ok = true;
        if(s.size() + 1 == t.size()) {
            for(int i = 0; i < s.size(); i++) {
                if(s[i] != t[i])
                    ok = false;
            }
        }
        else
            ok = false;

        if(ok)
            cout << "Yes\n";
        else
            cout << "No\n";
    }
    
    return 0;
}



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


int main(){
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<3;i++){
        if(s[i]=='1') ans++;
    }
    cout<<ans;
    return 0;
}


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

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)
#define INF 1000000000
#define MOD 1000000007

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

struct UF
{
	vector<int> par; // 親
	// 初期化
	UF(int n):par(n) {
		for(int i = 0; i < n; i++){
			par[i] = i;
		}
	}
	// 木の根を求める
	int find(int x) {
		if (par[x] == x) return x;
		else return par[x] = find(par[x]);
	}
	// xとyの属する集合を併合
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return;
		// 木の高さが高い方を代表ノードにする
		par[x] = y;
	}
	// xとyが同じ集合ならtrue
	bool same(int x, int y) { return find(x) == find(y); }
};

vector<pair<ll,pair<ll,ll> > > v;

ll kruskal(int n)
{
	sort(ALL(v));
	UF uf(n);
	
	ll ret = 0;
	
	REP(i,v.size())
	{
		pair<ll,pair<ll,ll> > e = v[i];
		if(!uf.same(e.SE.FI,e.SE.SE))
		{
			uf.unite(e.SE.FI,e.SE.SE);
			ret += e.FI;
		}
	}
	return ret;
}

ll kruskal(int n,int edge)
{
	UF uf(n);
	
	ll ret = 0;
	
	uf.unite(v[edge].SE.FI,v[edge].SE.SE);
	ret += v[edge].FI;
	
	REP(i,v.size())
	{
		pair<ll,pair<ll,ll> > e = v[i];
		if(!uf.same(e.SE.FI,e.SE.SE))
		{
			uf.unite(e.SE.FI,e.SE.SE);
			ret += e.FI;
		}
	}
	return ret;
}


int n,m;
ll x;

int main()
{
	cin >> n >> m >> x;
	REP(i,m)
	{
		ll a,b,c;cin >> a >> b >> c;
		a--;b--;
		v.PB(MP(c,MP(a,b)));
	}
	ll ans = 1;
	ll tmp = kruskal(n);
	if(tmp > x){
		cout << 0 << endl;
		return 0;
	}
	bool ok = false;
	int tyoudo = 0;
	int kake = 0;
	if(tmp != x)tyoudo++;
	
	REP(i,m){
		tmp = kruskal(n,i);
		//cout << tmp << endl;
		if(tmp == x)tyoudo++;
		else if(tmp > x)kake++;
	}
	REP(i,tyoudo){
		ans = (ans * 2) % MOD;
	}
	ans -= 2;
	if(ans < 0)ans += MOD;
	REP(i,kake){
		ans = (ans * 2)%MOD;
	}
	
	//cout << tyoudo << endl;
	//cout << kake << endl;
	
	if(tyoudo == 0){
		cout << 0 << endl;
		return 0;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define mii         map<ll int,ll int>
#define msi         map<string,ll int>
#define mis         map<ll int, string>
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define mpi         map<pair<ll int,ll int>,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define vii         vector<pair<ll int, ll int>>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
//#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;
#define N  1000000007 
#define MAXN   200005
 //priority_queue<int, vector<int>, greater<int> > Q; 
ll int n,x,a,b;
vector<ll int>adj[MAXN];
//vector<ll int>dis1(MAXN);
//vector<ll int>dis2(MAXN);
vector<bool>vis(MAXN);
ll int dp[MAXN][2];
void dfs(ll int s)
{
vis[s]=1;
/*if(adj[s].size()==1 && vis[adj[s][0]]==1)
{
dp[s][0]=1;
dp[s][1]=1;
return;	
}*/
for(auto j:adj[s])
{
if(!vis[j])
{dfs(j);
dp[s][0]=(dp[s][0]%N*(dp[j][0]+dp[j][1])%N)%N;
dp[s][1]=(dp[s][1]%N*dp[j][0]%N)%N;
}
}
}

int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n;
rep(i,0,n-1)
{
cin>>a>>b;
adj[a].pb(b);
adj[b].pb(a);
}
rep(i,0,n+1)
{dp[i][0]=1;dp[i][1]=1;}
dfs(1);
cout<<(dp[1][0]+dp[1][1])%N;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long N = l[0], P = l[1];

            var prime = PrimeFactorsDictionary(P);
            var ans = 1L;
            foreach (var p in prime)
            {
                for (var i = 0; i < p.Value / N; i++)
                    ans *= p.Key;
            }

            Console.WriteLine(ans);
        }


        public static Dictionary<long, int> PrimeFactorsDictionary(long n)
        {
            var dict = new Dictionary<long, int>();

            for (var p = 2L; p * p <= n; p++)
            {
                if (n % p != 0) continue;
                var num = 0;
                while (n % p == 0)
                {
                    num++;
                    n /= p;
                }

                dict[p] = num;
            }

            if (n != 1)
                dict[n] = 1;

            return dict;
        }
    }
}

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

typedef long long ll;
#define pii pair<ll , ll>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 15

int p[MAXX];
int q[MAXX];
int a[MAXX];

int main()
{
    _FastIO;
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> p[i];
        a[i] = i + 1;
    }
    for(int i = 0; i < n; i++){
        cin >> q[i];
    }
    int x = 0;
    int cnt = 0;
    do{
            cnt++;
            bool flag = true;
        for(int i = 0; i < n; i++){
            if(a[i] != p[i])
                flag = false;
        }
    if(flag)
        x = cnt;
    }while(next_permutation(a , a + n));

    int y = 0;
    cnt = 0;
    sort(a , a + n);
    do{
            cnt++;
            bool flag = true;
        for(int i = 0; i < n; i++){
            if(a[i] != q[i])
                flag = false;
        }
    if(flag)
        y = cnt;
    }while(next_permutation(a , a + n));

    cout << abs(x - y) << endl;
    return 0;
}


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

int main()
{
  int n,a,b;
  cin >> n >> a >> b;
  
  if( (a % 2) == (b % 2) ){
    cout << "Alice" << endl;
  }else{
    cout << "Borys" << endl;
  }
}

Measured memory_bytes: 3632
#
import sys
import math
import itertools


# 整数をいくつか入力
n,x,m = (int(i) for i in input().split())

if n < 100000:
    b=0
    for i in range(n):
        b += x
        #print(x)
        x = (x*x) %m
    print(b)
else:
    ll=[0]*100000
    s=0
    for i in range(100000):
        ll[i]=x
        s += x
        x = (x*x) %m
    for i in range(99998,-1,-1):
        if ll[i]==ll[99999]:
            term=99999-i
    p=(n-100000)//term
    q=(n-100000)%term
    r=0
    for i in range(term):
        r += ll[100000-term+i]
    s += r * p
    for i in range(q):
        s += ll[100000-term+i]
    print(s)



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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
	int n;
	cin >> n;
	vector<int> p(n);
	for(int i = 0; i < n; ++i)
	{
		cin >> p[i];
	}

	int ans = 0;
	for(int i = 1; i < n - 1; ++i)
	{
		if (p[i - 1] < p[i] && p[i] < p[i + 1])ans++;
		if (p[i + 1] < p[i] && p[i] < p[i - 1])ans++;
	}
	cout << ans;
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 3644
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class GFG
{
    static public void Main()
    {
        try
        {

            var input1 = Console.ReadLine().Split(' ');
            var n = int.Parse(input1[0]);
            var L = int.Parse(input1[1]);

            var aar = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();

            KnotPuzzle(n, L, aar);
        }
        catch (Exception ex)
        {
            Console.Write(ex);
        }
    }

    static void KnotPuzzle(int n, int L, int[] arr)
    {

        int index = 0;

        for (int i = 1; i < n; i++)
        {
            if (arr[i] + arr[i - 1] >= L)
            {
                index = i;
                break;
            }
        }

        if (index > 0)
        {

            Console.Write("Possible");
            Console.WriteLine();
            for (int k = 1; k < index; k++)
            {
                Console.Write(k);
                Console.WriteLine();
            }
            for (int k = n - 1; k >= index; k--)
            {
                Console.Write(k);
                Console.WriteLine();
            }
        }
        else
        {
            Console.Write("Impossible");
        }

    }

}

Measured memory_bytes: 29788
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 3
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	x := getNextInt(scanner) - 1
	y := getNextInt(scanner) - 1

	if x > y {
		x, y = y, x
	}

	ans := make([]int, n)
	for i := 0; i < n; i++ {
		for j := 0; j < i; j++ {
			a := i - j
			sc := absint(x-j) + absint(y-i) + 1
			if a > sc {
				a = sc
			}
			ans[a]++
		}
	}
	for k := 1; k < n; k++ {
		fmt.Fprintln(writer, ans[k])
	}
}

func absint(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 640
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scan=new Scanner(System.in);
		int A=scan.nextInt();
		int B=scan.nextInt();
		long ans=B;
		for(int i=A;i!=1;i--) {
			ans*=B-1;
		}
		System.out.println(ans);
	}
}

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

int main(){
  int N;
  cin>>N;
  int total=0;
  int temp=0;
  for(int i=1;i<=N;i++){
    for(int j=1;j<=N;j++){
      for(int k=1;k<=N;k++){
        temp=gcd(gcd(i,j),k);
        total=total+temp;
      }
    }
  }
  cout<<total<<endl;
  return 0;
}


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

#define F first
#define S second
#define PB push_back
#define all(x) x.begin(), x.end()

typedef long long ll; 
typedef long double ld;

const int N = 10000 * 100 + 10, M = 210; 
const int mod = 1000 * 1000 * 1000 + 7;

int fact[N], inv[N];

int tv(int x, int y)
{
	if(!y) return 1;
	ll ans = tv(x, y / 2);
	ans *= ans; ans %= mod;
	if(y & 1) ans *= x;
	return ans % mod;
}

int c(int x, int y)
{
	if(y > x) return 0;
	return 1ll * fact[x] * inv[y] % mod * inv[x - y] % mod;
}

int32_t main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	fact[0] = 1;
	for(int i = 1; i < N; i++) fact[i] = 1ll * fact[i - 1] * i % mod;
	inv[N - 1] = tv(fact[N - 1], mod - 2);
	for(int i = N - 2; i > -1; i--) inv[i] = 1ll * (i + 1) * inv[i + 1] % mod;
	int n, m;
	cin>> n >> m;
	int t = tv(2, mod - 2);
	int p = 0, q = 0;
	for(int i = 0; i < n + m; i++)
	{
		cout<< 1ll * (1ll + p - q + mod) * t % mod << '\n';
		p += 1ll * c(i, m - 1) * tv(t, i + 1) % mod; p %= mod;
		q += 1ll * c(i, n - 1) * tv(t, i + 1) % mod; q %= mod;
	}	
}


Measured memory_bytes: 9984
#include<bits/stdc++.h>
using namespace std;
int mon[3]={300000,200000,100000};
int main()
{
	int a,b;
	cin>>a>>b;
	int ans=0;
	if(a<=3)
	{
		ans+=mon[a-1];
	}
	if(b<=3)
	{
		ans+=mon[b-1];
	}
	if(a==1&&b==1)
	{
		ans+=400000; 
	}
	cout<<ans; 
	return 0;
}

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

const int MAXN = 8001;

int dx, dy;
std::bitset<MAXN << 1> x, y;

int main() {
    x[MAXN] = 1; y[MAXN] = 1;
    int first = 1, dist = 0, len = 0;
    while (char c = getchar()) {
        if (c == 'F') len ++;
        else {
            if (len) {
                auto &z = dist ? y : x;
                if (first) {
                    z <<= len;
                } else {
                    z = (z >> len) | (z << len);
                }
                len = 0;
            }
            first = 0;
            dist ^= 1;
            if (c == '\n') break;
        }
    }
    scanf("%d %d\n", &dx, &dy);
    if (x[MAXN + dx] && y[MAXN + dy]) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}


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

int dp[100000][13] = {0};
int MO = 1000000007;

int main(){
    string S; cin >> S;
    int N = S.size();
    int mod = 10;

    if(S[N-1]=='?') rep(i, 10) dp[0][i] = 1;
    else dp[0][S[N-1] - '0'] = 1;

    rep(i, N-1){
        if (S[N-2-i] != '?'){
            int index = mod * int(S[N-2-i] - '0') % 13;
            rep(j, 13) {
                dp[i+1][(j+index)%13] = dp[i][j];
            }
        }

        else{
            rep(j, 10){
                int tmp = (mod * j) % 13;
                rep(k, 13) dp[i+1][(k+tmp)%13] = (dp[i][k] + dp[i+1][(k+tmp)%13]) % MO;
            }
        }

        mod = (mod * 10) % 13;
    }

    cout << dp[N-1][5] << endl;
}


Measured memory_bytes: 5504
if __name__ == '__main__':
	N = int(input())
	X = [int(x) for x in input().split()]

	ans = 10000000

	for i in range(1,101):
		s = 0
		for x in X:
			s += (x-i)**2

		if ans > s:
			ans = s

	print(ans)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int Factri(int n){
    int v=1;
    rep(i,2,n+1) v*=i;
    return v;
}

int Comb(int n,int m){
    return Factri(n)/Factri(m)/Factri(n-m);
}

int main(){
    int N; cin>>N;
    string S1,S2; cin>>S1>>S2;

    int64_t ans=1,next=3; 
    rep(i,0,N){
        if(S1.at(i)==S2.at(i)){
            ans*=next;
            ans%=MOD;
            next=2;
        }else{
            if(next==1) ans*=3;
            else ans*=2*Comb(next,2);
            ans%=MOD;
            next=1;
            i++;
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
import math
def MI(): return map(int, input().split())
def II(): return int(input())
def IS(): return input()
def LI(): return list(map(int, input().split()))


n = II()
a = LI()
a.insert(0,0)
a.append(0)
diff = [abs(a[i] - a[i-1]) for i in range(1,len(a))]
money = sum(diff)
# print(a)
# print(diff)
for i in range(1,len(a)-1):
    if a[i-1] <= a[i] <= a[i+1]:
        print(money)
    elif a[i+1] <= a[i] <= a[i-1]:
        print(money)
    elif a[i] <= a[i-1] <= a[i+1]:
        print(money-2*abs(a[i-1]-a[i]))
    elif a[i+1] <= a[i-1] <= a[i]:
        print(money-2*abs(a[i-1]-a[i]))
    elif a[i-1] <= a[i+1] <= a[i]:
        print(money-2*abs(a[i+1]-a[i]))
    else:
        # a[i] <= a[i+1] <= a[i-1]
        print(money-2*abs(a[i+1]-a[i]))


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


int main() {
long N,M,K;
cin>>N>>M>>K;
vector<long> a(N);
vector<long> b(M);
vector<long> A(N+1);
vector<long> B(M+1);
for(int i=0;i<N;i++){
  cin>>a[i];
}
for(int i=0;i<M;i++){
  cin>>b[i];
}

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

for(int i=1;i<=M;i++){
  B[i]=B[i-1]+b[i-1];
}
long ans=0;
int j=M;
for(int i=0;i<=N;i++){
  long t=A[i];
  while(j>=0){
    if(t+B[j]>K) j--;
    else{
      t+=B[j];
      break;
    }
  }
  if(t<=K){
    //cout<<i<<j<<endl;
    ans=max(ans,long(i+j));
  }
}

cout<<ans<<endl;

}


Measured memory_bytes: 9592
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>

using namespace std;

typedef pair<string, int> P;
long long int INF = 1e18;
long long int MOD = 1000000007;

int main(){
	
	int a, b;
	cin >> a >> b;
	
	if(a + b == 15){
		cout << "+" << endl;
	}else if(a * b == 15){
		cout << "*" << endl;
	}else{
		cout << "x" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9;
using namespace std;
using ll = long long;
int main() {
    int X , A , B;
    cin >> X >> A >> B;
    if(A >= B){
        cout << "delicious" << endl;
    }
    else if(A + X >= B){
        cout << "safe" << endl;
    }
    else{
        cout << "dangerous" << endl;
    }
}


Measured memory_bytes: 3572
from collections import Counter
S=Counter(list(input())).most_common()
if len(S)==1:
    if S[0][1]!=1:
        print("NO")
    else:
        print("YES")
elif len(S)==2:
    if S[0][1]+S[1][1]>=3:
        print("NO")
    else:
        print("YES")
else:
    if S[0][1]>S[2][1]+1 or S[1][1]>S[2][1]+1 :
        print("NO")
    else:
        print("YES")


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

int main(int argc, char const *argv[])
{
	int r;
	cin>>r;
	if (r<1200)
	{
		cout<<"ABC\n";
	}
	else if (r<2800)
	{
		cout<<"ARC\n";
	}
	else
	{
		cout<<"AGC\n";
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;

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

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CIN(int, X);

    for (int i = sqrt(X); i <= X; i++) {
        if ( i*i+i >= 2*X ) {
            cout << i << "\n";
            break;
        }
    }

    return 0;
}

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

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

	int n; cin >> n;
	int a[n], ans = 0;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	for (int i = 1; i < n - 1; i++)
	{
		if (a[i - 1] < a[i]  && a[i] < a[i + 1])
		{
			ans++;
		}
		else if (a[i - 1] > a[i] && a[i] > a[i + 1])
		{
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3596
s = gets.chomp.split('')
a = (s[0] << s[1]).to_i
b = (s[2] << s[3]).to_i
if a > 0 && a <= 12
  if b > 0 && b < 13
    puts :AMBIGUOUS
  else
    puts :MMYY
  end
elsif a >= 0 && a <= 99
  if b > 0 && b < 13
    puts :YYMM
  elsif b > 13 || b <= 0
    puts :NA
  end
elsif a == 0 && b == 0
  puts  :NA
end

Measured memory_bytes: 1916
from collections import deque

h,w = map(int,input().split())
dg = 30

s = [['#']*(w+2)]
for _ in [0]*h:
    s.append(['#'] + list(input()) + ['#'])
s.append(['#']*(w+2))

res = 0
for i in range(1,h+1):
    for j in range(1,w+1):
        if s[i][j] == '#':
            continue
        d = [[0]*(w+2) for _ in [0]*(h+2)]
        
        start = i*dg+j
        tank = deque([start])
        while tank:
            x = tank.popleft()
            
            go = x-dg
            if go != start and s[go//dg][go%dg] == '.' and d[go//dg][go%dg] == 0:
                d[go//dg][go%dg] = d[x//dg][x%dg] + 1
                res = max(res,d[go//dg][go%dg])
                tank.append(go)
            go = x+dg
            if go != start and s[go//dg][go%dg] == '.' and d[go//dg][go%dg] == 0:
                d[go//dg][go%dg] = d[x//dg][x%dg] + 1
                res = max(res,d[go//dg][go%dg])
                tank.append(go)
            go = x+1
            if go != start and s[go//dg][go%dg] == '.' and d[go//dg][go%dg] == 0:
                d[go//dg][go%dg] = d[x//dg][x%dg] + 1
                res = max(res,d[go//dg][go%dg])
                tank.append(go)
            go = x-1
            if go != start and s[go//dg][go%dg] == '.' and d[go//dg][go%dg] == 0:
                d[go//dg][go%dg] = d[x//dg][x%dg] + 1
                res = max(res,d[go//dg][go%dg])
                tank.append(go)

print(res)

Measured memory_bytes: 69228
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	ll N,A,B;
	cin>>N>>A>>B;
	ll nax = A + B*(N-1);
	ll nin = B + A*(N-1);
	cout<<max(0LL, nax - nin + 1LL)<<endl;
	return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class DDoubleDots {
public:
    int N, M;
    vc<int> used, par;
    vvc<int> G;

    void bfs(int s){
        queue<int> que;
        used[s] = 1;
        que.push(s);
        while(not que.empty()){
            int u = que.front(); que.pop();
            for(auto v : G[u]){
                if(used[v]) continue;
                used[v] = 1;
                par[v] = u;
                que.push(v);
            }
        }
    }

    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        in>>N>>M;
        used.resize(N, 0);
        par.resize(N, -1);
        G.resize(N);
        REP(i, M){
            int a, b;
            in>>a>>b;
            a--, b--;
            G[a].pb(b), G[b].pb(a);
        }
        bfs(0);
        out<<"Yes\n";
        FOR(i, 1, N) out<<par[i]+1<<'\n';
    }
};


int main() {
	DDoubleDots solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 10680
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		for (int n; (n = s.nextInt()) > 0;) {
			char[] c = new char[n];
			int[][] a = new int[n][3];
			for (int i = 0; i < n; ++i) {
				c[i] = s.next().charAt(0);
				a[i][0] = i;
				for (int j = 1; j < n; ++j) {
					int x = s.nextInt();
					if (x == 0) {
						++a[i][1];
					} else if (x == 1) {
						++a[i][2];
					}
				}
			}
			Arrays.sort(a, new Comparator<int[]>() {
				@Override
				public int compare(int[] o1, int[] o2) {
					if (o2[1] == o1[1]) {
						if (o1[2] == o2[2]) {
							return o1[0] - o2[0];
						} else {
							return o1[2] - o2[2];
						}
					}
					return o2[1] - o1[1];
				}
			});
			for(int i = 0; i < n; ++i){
				System.out.println(c[a[i][0]]);
			}
		}
	}
}

Measured memory_bytes: 12000
l=input()
a=len(l)
mod=10**9+7
ans=3**a%mod
t=0
for i,j in enumerate(l,1):
    if(j=="0"):
        ans-=pow(3,a-i,mod)*pow(2,t+1,mod)
    else:
        t+=1
print(ans%(10**9+7))

Measured memory_bytes: 41196
import sys

N,K = map(int, sys.stdin.readline().strip().split())

if K == 1:
    print(0)
    sys.exit()
if N == K:
    print(0)
    sys.exit()

d = []

d.append(N % K)
while True:
    d.append(abs(d[-1] - K))
    if d[-1] > d[-2]:
        print(d[-2])
        sys.exit()


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

using namespace std;

long long a[100000];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    long long l;
    cin >> n >> l;
    for (int i = 0; i < n; i++) cin >> a[i];
    long long sum = 0;
    int last = 0;
    for (int i = 1; i < n; i++) {
        long long tmp = a[i - 1] + a[i];
        if (tmp > sum) {
            sum = tmp;
            last = i;
        }
    }
    if (sum < l) cout << "Impossible\n";
    else {
        cout << "Possible\n";
        for (int i = 1; i < last; i++) cout << i << "\n";
        for (int i = n - 1; i > last; i--) cout << i << "\n";
        cout << last << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 1664
// Package main provides
//
// File:  a.go
// Author: ymiyamoto
//
// Created on Sat Dec  1 15:38:26 2018
//
package main

import "fmt"

var s string

func main() {
	fmt.Scan(&s)

	for _, c := range s {
		if c == '1' {
			fmt.Print(9)
		} else {
			fmt.Print(1)
		}
	}
	fmt.Println()
}


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

bool dfs(int v,const int s,vector<multiset<int>> &edge,bool first){
  if(!first && v==s){return true;}
  if(edge[v].size()==0) return false;
  auto it=edge[v].begin();
  int to=*it;
  edge[v].erase(it);
  it=lower_bound(edge[to].begin(),edge[to].end(),v);
  edge[to].erase(it);
  return dfs(to,s,edge,false);
}

int main(){
  int n,m;
  cin>>n>>m;
  vector<multiset<int>> edge(n);
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    a--,b--;
    edge[a].insert(b);
    edge[b].insert(a);
  }
  for(int i=0;i<n;i++){
    while(edge[i].size()!=0){
      if(!dfs(i,i,edge,true)){
	cout<<"NO"<<endl;
	return 0;
      }
    }
  }
  cout<<"YES"<<endl;
  return 0;
}


Measured memory_bytes: 14464
use std::io;

fn read_line() -> String {
  let mut line = String::new();
  io::stdin()
    .read_line(&mut line)
    .ok();
  line
}

fn is_within(v: i32, l: i32, g: i32) -> bool {
  if v >= l && v <= g {
    true
  }
  else {
    false
  }
}

fn main() {
  let line = read_line();

  let v: Vec<i32> = line.trim()
    .split_whitespace()
    .map(|val| { val.parse().unwrap() })
    .collect();
  
  let (w, h, x, y, r) = (v[0], v[1], v[2], v[3], v[4]);

  let ans = if is_within(x, r, w - r) && is_within(y, r, h - r) {
    "Yes"
  }
  else {
    "No"
  };

  println!("{}", ans);
}



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

typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define all(v) v.begin(), v.end()
#ifdef LOCAL
  #define de(e) cout << "L" << __LINE__ << ": " << e << "\n" // debug echo
  #define dr(e) cout << "L" << __LINE__ << ": " << #e << " -> " << e << "\n" // debug repr
#else
  #define de(e)
  #define dr(e)
#endif
#define out(fmt, ...) printf(fmt, __VA_ARGS__); printf("\n")
int gcd(int m, int n) { if((0 == m) || (0 == n)){return 0;} while(m != n){ if(m > n){m -= n;}else{n -= m;} } return m; }
int lcm(int m, int n) { if((0 == m) || (0 == n)){return 0;} return (m / gcd(m, n)) * n; }

//
// Implementation
//

int main() {
  int A, B, C, D, P;
  scanf("%d %d %d %d %d", &A, &B, &C, &D, &P);
  int X = A*P;
  int Y = B + max(P-C, 0)*D;
  if (X < Y) {
    out("%d", X);
  } else {
    out("%d", Y);
  }
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int main() {
	int n = ri();
	double a[n];
	for (auto &i : a) scanf("%lf", &i);
	double dp[n + 1][n + 1];
	for (int i = 0; i <= n; i++) for (int j = 0; j <= n; j++) dp[i][j] = 0;
	dp[0][0] = 1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n - i; j++) {
			dp[i + 1][j] += dp[i][j] * a[i + j];
			dp[i][j + 1] += dp[i][j] * (1 - a[i + j]);
		}
	}
	double res = 0;
	for (int i = 0; i <= (n - 1) / 2; i++) res += dp[n - i][i];
	printf("%.11f\n", res);
	return 0;
}


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

#define INF INT_MAX
#define N 101
#define W 1000000009
#define V 100002

using namespace std;

int n, w;
int weight[N];
int value[N];
int dp[N][V];
int solve(int idx, int v){
    if(idx == n && v == 0)
        return 0;
    if(idx == n || v < 0)
        return W;
    if(~dp[idx][v])
        return dp[idx][v];
    int take = solve(idx+1, v-value[idx]) + weight[idx];
    int leave = solve(idx+1, v);
    return dp[idx][v] = min(take,leave);
}
int main()
{
    scanf("%d %d", &n, &w);
    for(int i=0; i<n; ++i)
        scanf("%d %d", &weight[i], &value[i]);
    memset(dp, -1, sizeof(dp));
    for(int i = V-1;  i>=1; --i){
        // int res = solve(0, i);
        // cout << res << endl;
        // if(res <= w){
        if(solve(0, i) <= w){
            // cout << i;
            printf("%d", i);
            break;
        }
    }
    return 0;
}


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

inline int read()
{
	int sum=0,ff=1; char ch=getchar();
	while(!isdigit(ch))
	{
		if(ch=='-') ff=-1;
		ch=getchar();
	}
	while(isdigit(ch))
		sum=sum*10+(ch^48),ch=getchar();
	return sum*ff;
}


const int N=2e5+5;
int n,ans;
string s[N];
map<string,int>mp;

int main()
{
	n=read();
	for ( int i=1; i<=n; ++i ) cin>>s[i];
	sort(s+1,s+n+1);
	for ( int i=1; i<=n; ++i ) mp[s[i]]++;
	for ( int i=1; i<=n; ++i ) ans=max(ans,mp[s[i]]);
	for ( int i=1; i<=n; ++i )
	if (mp[s[i]]==ans) 
	{
		cout<<s[i]<<endl;
		mp[s[i]]--;	
	}
	return 0;	
}

Measured memory_bytes: 26880
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <iterator>
#include <cmath>
#include <deque>
#include <stack>
#include <functional>
#include <queue>
using namespace std;



signed main()
{
    {
        if (fopen("input.txt", "r")) {
            freopen("input.txt", "r", stdin);
            freopen("output.txt", "w", stdout);
        }
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
    }

    int n, r;
    cin >> n >> r;
    if (n >= 10)
        cout << r;
    else
        cout << r + 100 * (10 - n);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <unordered_map>
#include <vector>
#include <string.h>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()

int dx[] = { 1, -1, 0, 0 };
int dy[] = { 0, 0, 1, -1 };

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

int gcd(int a, int b) {
  if (a < b) { swap(a, b); }
  if (b == 0) { return a; }
  return gcd(b, a % b);
}

bool prime(int n) {
  for (int i = 2; i <= sqrt(n); ++i) {
    if (n % i == 0) { return false; }
  }
  return n != 1;
}

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

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

ll powmod(ll x, ll n) { // like pow(x, n)
  ll r = 1;
  while (n) {
    if (n & 1) {
      r = r * x % MOD;
    }
    x = x * x % MOD;
    n >>= 1;
  }
  return r;
}

const int COM_MAX = 500010;
ll fac[COM_MAX], facinv[COM_MAX], inv[COM_MAX];
void COMinit() {
  fac[0] = fac[1] = 1;
  facinv[0] = facinv[1] = 1;
  inv[1] = 1;
  for(int i = 2; i < COM_MAX; ++i) {
    fac[i] = fac[i-1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    facinv[i] = facinv[i-1] * inv[i] % MOD;
  }
}

ll COM(ll n, ll k) {
  return (fac[n] * facinv[k] % MOD) * facinv[n-k] % MOD;
}

ll PERM(ll n, ll k) {
  return (fac[n] * facinv[k] % MOD);
}

class UnionFind {
public:
  UnionFind(int size) : par(size, -1) {}

  bool same(int x, int y) {
    return root(x) == root(y);
  }
  void unite(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return;
    if (x > y) { swap(x, y); }
    // here, x < y
    par[y] = x;
  }
  int root(int x) {
    if (par[x] < 0) {
      return x;
    } else {
      return par[x] = root(par[x]);
    }
  }

private:
  vector<int> par;
};

int main(int argc, char** argv) {
  ll N, M, Q;
  cin >> N >> M >> Q;

  UnionFind tree(N);
  vector<P> edges; // different edges.
  rep(i, Q) {
    ll A, B, C;
    cin >> A >> B >> C;
    if (C == 0) {
      tree.unite(A, B);
    } else {
      edges.emplace_back(A, B);
    }
  }

  if (M == N - 1) { // G must be a tree.
    if (edges.size() == 0) {
      cout << "Yes" << endl;
      return 0;
    } else {
      cout << "No" << endl;
      return 0;
    }
  }

  // Check different edges
  for (auto e : edges) {
    if (tree.same(e.first, e.second)) {
      cout << "No" << endl;
      return 0;
    }
  }

  set<int> st;
  rep(i, N) {
    int r = tree.root(i);
    st.insert(r);
  }
  ll K = st.size(); // the number of connected components.

  // H must be lower than or equals to (N-K) + K*(K-1)/2 = N + K(K-3)/2
  if (M <= N + K * (K - 3) / 2) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 6896
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define fast ios_base::sync_with_stdio(false)
typedef long long ll;
typedef pair<ll,ll> p;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll power(ll x, ll y, ll p=mod)
{ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1;x = (x*x) % p;}return res;}
int main()
{
fast;
ll n;
cin>>n;
vector<ll>v1,v2;
for(ll i=0;i<n;i++)
{
    ll a;
    cin>>a;
    v1.pb(a);
}
vector<ll>v;
for(ll i=0;i<n;i++)
{
    ll a;
    cin>>a;
    v2.pb(a);
}

for(ll i=1;i<=n;i++)
{
    v.pb(i);
}
sort(v.begin(),v.end());
ll a=0,b=0;
ll cnt=1;
do{
    if(v1==v)
    {
        a=cnt;
    }
    if(v2==v)
    {
        b=cnt;
    }

    cnt++;
}while(next_permutation(v.begin(),v.end()));
cout<<fabs(a-b)<<endl;
return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		
		int[] a = new int[9];
		for(int i = 0; i < 9; i++){
			a[i] = sc.nextInt();
		}
		int b1 = a[0];
		int b2 = a[1];
		int b3 = a[2];
		
		int a1 = 0;
		int a2 = a[3] - b1;
		int a3 = a[6] - b1;
		
		int check = 0;
		if(a[4] != a2 + b2 || a[5] != a2 + b3 || a[7] != a3 + b2 || a[8] != a3 + b3){
			check++;
		}
		
		if(check == 0){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 23124
#include <stdio.h>
#define N 100
int main(){
  int i,j,A[N],n,flag,t,cnt=0;

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);

  for(i=0;i<n-1;i++){
    flag=0;
    for(j=n-1;j>=i+1;j--){
      if(A[j]<A[j-1]){
	t=A[j];A[j]=A[j-1];A[j-1]=t;
	flag=1;
	cnt++;
      }
    }
  }

  for(i=0;i<n;i++){
    printf("%d",A[i]);
    if(i!=n-1) printf(" ");
  }
  printf("\n%d\n",cnt);
  return 0;
}
	
  



Measured memory_bytes: 2140
X, N = map(int, input().split())
if N == 0:
    print(X)
    exit()

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

for i in range(N + 1):
    if X - i not in list_p:
        print(X - i)
        exit()
    elif X + i not in list_p:
        print(X + i)
        exit()

Measured memory_bytes: 9184
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
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, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
//#define int ll

const int md = 1000000007;
const int INF = 1<<30;



int main(){
    int n,m ; cin  >> n >> m;
    vector<vector<int>> s(m,vector<int>(n+1,0));
    vi p(m);
    rep(i,m){
        int k; cin >> k;
        rep(j,k){
            int tmp; cin >> tmp;
            s[i][tmp-1] = 1;
        }
    }

    cin >> p;

    int ans = 0;
    rep(i,1<<n){
        bool flag = true;
        vector<bool> f(n, false);
        rep(j,n){
            if((i >> j) & 1) f[j] = true;
        }
        rep(j,m){
            int cnt = 0;
            rep(k,n){
                if(s[j][k] == 1 and f[k]) cnt++;
            }
            if(cnt%2 != p[j]) flag = false;
        }
        if(flag) ans++;
    }

    cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
  int K; cin >> K;
  int term = 1;
  bool existing[K] = {false};
  int mod = 7 % K;
  existing[mod] = true;
  while (true){
    if (mod % K == 0) break;
    mod = (mod * 10 + 7) % K;
    if (existing[mod]){
      cout << "-1";
      return 0;
    }
    existing[mod] = true;
    term++;
  }
  cout << term;
}


Measured memory_bytes: 4536
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int a,b,c;
    int s[200000];
    cin >> a >> b;
    c = 0;
    for(int i=0; i<b; i++){
        cin >> s[i];
    }
    
    sort(s, s+b);
    for(int j=1; j<b; j++){
        if(c < s[j]-s[j-1]){
            c = s[j]-s[j-1];
        }
    }
    if(c < a+s[0]-s[b-1]){
        c = a+s[0]-s[b-1];
    }
    
    cout << a - c << endl;
    
}

Measured memory_bytes: 1024
n = int(input())

import math
def divisor(n):
    a = set()
    for i in range(1, math.ceil(n**0.5) + 1):
        if n % i == 0:
            a.add(i)
            a.add(n // i)
    return a
x = [0] * (n+1)
for i in range(1, n+1):
    for j in range(i, n+1, i):
        x[j] += 1
ans = 0
for i in range(n+1):
    #print(i,x[i],divisor(i))
    ans += (i * x[i])
print(ans)


Measured memory_bytes: 146176
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	if a < b {
		fmt.Println("a < b")
	} else if a > b {
		fmt.Println("a > b")
	} else if a == b {
		fmt.Println("a == b")
	}
}



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

int main() 
{ 
int n,k;
cin>>n>>k;
int a[n];
for(int y=0;y<n;y++)
cin>>a[y];
vector<int> g[n+1];
for(int y=0;y<k;y++){
    int u,v;
    cin>>u>>v;
    g[u].push_back(v);
    g[v].push_back(u);
}
int ans=0;
for(int y=1;y<=n;y++){
    int o=0;
    for(auto i:g[y]){
        if(a[y-1]<=a[i-1]){
            o=1;
            break;
        }
    }
    if(o==0){//cout<<y<<endl;
    ans++;}
}
cout<<ans;
} 


Measured memory_bytes: 9100
let nk = readLine()!.split(separator: " ")
let n = Int(nk[0])!
let k = Int(nk[1])!
let mod = 1000000007

func pow(_ a: Int, _ n: Int, _ mod: Int? = nil) -> Int {
    var a = a
    var n = n
    var result: Int = 1
    if let unwrappedMod = mod {
        while n > 0 {
            if n & 1 == 1 {
                result = result * a % unwrappedMod
            }
            n >>= 1
            a = a * a % unwrappedMod
        }
        return result
    }
    else {
        while n > 0 {
            if n & 1 == 1 {result *= a}
            n >>= 1
            a *= a
        }
        return result
    }
}

var table = [Int: Int]()

for i in (1...k).reversed() {
    var tmp = pow((k / i), n, mod)
    for j in 2...k {
        if let unwrappedVal = table[j * i] {
            tmp -= unwrappedVal
        }
        else {break}
    }
    table[i] = tmp % mod
}

var result = 0
for (key, value) in table {
    result += key * value
    result %= mod
}
if result < 0 {
    result += mod
}

print(result)


Measured memory_bytes: 14052
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

const ll INF = 1ll << 62;

using P = pair<ll, int>;

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  while (cin >> N) {
    vector<P> A(N);
    for (int i = 0; i < N; i++) {
      cin >> A[i].fst;
      A[i].snd = i;
    }
    sort(A.rbegin(), A.rend());
    vector<ll> dp(N + 1, -INF);
    dp[0] = 0;
    for (int i = 0; i < N; i++) {
      vector<ll> ndp(N + 1, -INF);
      for (int l = 0; l <= i; l++) {
        int r = N - (i - l) - 1;
        chmax(ndp[l + 1], dp[l] + A[i].fst * (A[i].snd - l));
        chmax(ndp[l], dp[l] + A[i].fst * (r - A[i].snd));
      }
      dp = ndp;
    }
    ll res = *max_element(dp.begin(), dp.end());
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 3660
use std::io::stdin;

fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    let mut t = s.split_whitespace().map(|e| e.parse().unwrap());
    let n: i32 = t.next().unwrap();
    let m: i32 = t.next().unwrap();
    println!("{}", f(n) + f(m));
}

fn f(a: i32) -> i32 {
    if a < 2 {
        return 0;
    }

    return a * (a - 1) / 2;
}


Measured memory_bytes: 4352