akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 1000000000
#define INF 9223372036854775807
#define MOD 1000000007
#define mod 1000000007
#define INT_MAX_ 2147483647
#define EPS (1e-10)
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<ll,Pll> a,pair<ll,Pll> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se.fi>b.se.fi;
}
//----------------------------------------------------------------------
ll dp[500][500];
ll sum[500];V<ll>a;
bool flag[500][500];
ll f(ll l,ll r){
    if(flag[l][r])return dp[l][r];
    flag[l][r]=1;
    if(l==r)return 0;
    ll res=INF;
    for(ll m=l;m<r;m++){
        chmin(res,sum[r]-sum[l]+a[l]+f(l,m)+f(m+1,r));
    }
    dp[l][r]=res;
    //cout<<l<<" "<<r<<" "<<dp[l][r]<<endl;
    return dp[l][r];
}
//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_t=clock();
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //-------------------------------
    ll n;cin>>n;
    a.resize(n);
    for(ll i=0;i<n;i++)cin>>a[i];
    sum[0]=a[0];
    for(ll i=1;i<n;i++){
        sum[i]=sum[i-1]+a[i];
        //cout<<sum[i]<<endl;
    }
    for(ll i=0;i<500;i++){
        for(ll j=0;j<500;j++){
            dp[i][j]=INF;
        }
        dp[i][i]=0;
    }
    cout<<f(0,n-1)<<endl;
    //-------------------------------  
    //fclose(stdin);
    //fclose(stdout);
    //ll end_t=clock();cout<<"time="<<end_t-begin_t<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------







































Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define lli long long int
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF 9223372036854775807+1

int main() 
{
  string s;
  cin >> s;
  int ans=0;
  rep(i, (s.size())/2){
  if(s[i]!=s[s.size()-1-i])
    ans++;
  }
  cout << ans << endl;
}

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

int main(){
  int64_t N, A, B;
  cin >> N >> A >> B;
  if(N==1 && A!=B){
    cout << 0 << endl;
  }
  else if(N==1 && A==B){
    cout << 1 << endl;
  }
  else if(B<A){
    cout << 0 << endl;
  }
  else{
    cout << (B*(N-1)+A)-(B+A*(N-1))+1 << endl;
  }
}

Measured memory_bytes: 256
import sys
readline=sys.stdin.readline

X,N=map(int,readline().split())
P=set(list(map(int,readline().split())))


x = X
while x in P:
  x -= 1

minX = x

x = X
while x in P:
  x += 1
maxX = x

if abs(minX - X) <= abs(maxX - X):
  print(minX)
else:
  print(maxX)

Measured memory_bytes: 9200
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define ss second
#define ff first
#define mp make_pair
using namespace std;

int main() {
    ll i,flag=0;
    string s;
    cin>>s;
    map<ll,ll> mp1;
    for(i=0;i<4;i++){
        mp1[s[i]]++;
    }
    for(auto x : mp1){
        if(x.ss!=2){
            flag=1;
            break;
        }
    }
    if(flag==0){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}


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

struct info {
    int p;
    int y;
    int x;
};


int main(void)
{
    int n,m;
    cin >> n >> m;
    info py[NMAX];

    for(int i = 0; i < m;i++)  {
        cin >> py[i].p >> py[i].y;
    }
    vector<int> mp[NMAX];
    for(int i = 0; i < m; i++){
        mp[py[i].p].push_back(py[i].y);
    }
    for (int i = 0; i <= n; i++) {
        sort(mp[i].begin(), mp[i].end());
    }
    for (int i = 0; i < m; i++){
        auto itr = lower_bound(mp[py[i].p].begin(), mp[py[i].p].end(), py[i].y);
        py[i].x = (int) (itr - mp[py[i].p].begin()) + 1;
        cout << setw(6) << setfill('0') << py[i].p;
        cout << setw(6) << setfill('0') << py[i].x << endl;
    }

    return 0;
}


Measured memory_bytes: 8448
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >>n;
  for(int i=0;i<n;i++){
    int x,y,b,p;
    cin >>x>>y>>b>>p;
    int num=x*b+y*p;
    if(b<=4)b=5;
    if(p<=2)p=2;
    if(num>(x*b+y*p)*0.8)num=(x*b+y*p)*0.8;
    cout << num <<endl;
  }
}

Measured memory_bytes: 3108
import java.util.*;

public class Main {

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

        int n = sc.nextInt();
        long result = 0;
        for (int i = 1; i <= n; i++) {
            if (i % 3 != 0 && i % 5 != 0) {
                result += i;
            }
        }

        System.out.println(result);
    }
}

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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/
//bit全探索による解放
int main(){
    string s;cin>>s;
    for(int bit=0;bit<(1<<3);bit++){
        //bitが立っていれば+
        int tmp=s[0]-'0';
        V k(3);
        char ope[4];
        for(int i=0;i<3;i++){
            if(bit&(1<<i)){
                k[i]=1;
                tmp+=(s[i+1]-'0');
                ope[i]='+';
            }
            else{
                tmp-=(s[i+1]-'0');
                ope[i]='-';
            }
        }
        //rep(j,3)cout<<k[j];
        //printf("tmp=%d\n",tmp);
        if(tmp==7){
            cout<<s[0];
            rep(i,3){
                cout<<ope[i]<<s[i+1];
            }
            cout<<"=7"<<endl;
            break;
        }
    }
}


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

using namespace std;
typedef long long ll;
using Graph =vector<int>;
typedef pair<int,int> P;

const ll MAX_N=131072;

int bit[MAX_N*2-1];
ll n;
vector<int> G[1000010];
ll ans=0;
//combination
const int MAX = 210000;
const int MOD = 1000000007;
ll jun(int n,int k){
  if(n<k||n<0 || k<0) return 0;
  if(k==1) return n;
  return (n*jun(n-1,k-1))%MOD;
}
int main(){
  int N,K;cin>>N>>K;
  rep(i,N-1){
    int a,b;cin>>a>>b;
    a-=1;b-=1;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  queue<P> q;
  ll ans=K;
  if (G[0].size()!=0) q.push(P(-1,0));
  while(!q.empty()){
    P p=q.front();q.pop();
    int f=p.first;int t=p.second;
    if (f==-1){
      ans*=jun(K-1,G[t].size());
      ans%=MOD;
    }else{
      ans*=jun(K-2,G[t].size()-1);
      ans%=MOD;
    }
    for(auto v:G[t]){
      if (v==f || G[v].size()==1) continue;
      q.push(P(t,v));
    }
  }
  cout<<ans<<endl;
}


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

int main(void) {
	int a, b;
	int arr[14] = {0, 13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
	while(cin >> a >> b) {
		if(arr[a] > arr[b])
			cout << "Alice" << endl;
		else if(arr[a] < arr[b])
			cout << "Bob" << endl;
		else
			cout << "Draw" << endl;
	}

	return 0;
}

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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define dump(x)
#define debug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(long long N, long long M){
    cout << (N * (N-1) + M * (M-1)) / 2 << endl;
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    solve(N, M);
    return 0;
}


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

int main() {
  ll a;
  double b;
  cin >> a >> b;
  ll ib = b*100+0.5;
  a *= ib;
  a /= 100;
  cout << a << endl;
  return 0;
}


Measured memory_bytes: 3692
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    // 0 100 -> 101
    // 1 100 -> 10100
    // 2 100 -> 10
    int D, N;
    cin >> D >> N;
    if (N == 100) ++N;
    cout << N * static_cast<int>(pow(100, D)) << endl;
}


Measured memory_bytes: 256
A = gets.to_i
B = gets.to_i
C = gets.to_i
X = gets.to_i

count = 0

for coin_500 in 0..A do
  for coin_100 in 0..B do
    for coin_50 in 0..C do
      if coin_500 * 500 + coin_100 * 100 + coin_50 * 50 == X then
        count += 1
      end
    end
  end
end

p count

Measured memory_bytes: 1788
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[List[int]]"):
    #s_0 = sum(A[0])
    #s_1 = sum(A[1])
    ret = 0
    for i in range(N):
        tmp = sum(A[0][:i + 1]) + sum(A[1][i:])
        ret = max(ret, tmp)
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ [ int(next(tokens)) for _ in range(N) ] for _ in range(2) ]  # type: "List[List[int]]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main{

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int count = 999999999;
        for (int i = 1 ; i < N ; i ++) {
            int A = i;
            int a = 0;
            while (A > 0) {
                a += A  % 10;
                A /= 10;
            }
            int B = N - i;
            int b = 0;
            while (B > 0) {
                b += B % 10;
                B /= 10;
            }
            count = Math.min(count, a + b);

        }
        System.out.println(count);

    }

}


Measured memory_bytes: 22996
#include <cstdio>

int main(){
    char s[4];
    scanf("%s",s);
    int count = 0;
    for(int i = 0; i < 3; i++){
        if(s[i] == 'o'){
            count++;
        }
    }
    printf("%d\n",700 + 100 * count);

    return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

int32_t main() {
    //ios::sync_with_stdio(false); cin.tie(nullptr);
    
    int n, x, t;
    cin >> n >> x >> t;
    cout << t * (int) ceil((double) n / x);
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define all(n) (n).begin(),(n).end()
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}

int main(){
	int n;
	cin >> n;
	int d[100];
	FOR(i,n){
		cin >> d[i];
	}
	int ans=0;
	FOR(i,n-1){
		for(int j=i+1;j<n;j++){
			ans+=d[i]*d[j];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
macro_rules! input {
    ($ttype:ty) => {
        {
            let mut input = String::new();
            let _= std::io::stdin().read_line(&mut input);
            input.trim().parse::<$ttype>().unwrap()
        }
    };

    ($($ttype:ty),*) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let mut iter = input.trim().split_whitespace();
            (
                $(iter.next().unwrap().parse::<$ttype>().unwrap(),)*
            )
        }
    };

    ($ttype:ty; $x:expr) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let v: Vec<$ttype> = input
                .trim()
                .split_whitespace()
                .map(|x| x.parse().unwrap())
                .collect();
            v
        }
    };

    ($ttype:ty; $x:expr; $y:expr) => {
        {
            use std::io::BufRead;
            let mut matrix = Vec::with_capacity($y);
            for _ in 0..$y {
                let mut input = String::new();
                let stdin = std::io::stdin();
                let _ = stdin.lock().read_line(&mut input);
                let v: Vec<$ttype> = input
                    .trim()
                    .split_whitespace()
                    .map(|x| x.parse().unwrap())
                    .collect();
                matrix.push(v);
            }
            matrix
        }
    };
}

fn main() {
    let (x, y) = input!(i64, i64);

    let mut i: u32 = 1;
    while x * 2_i64.pow(i - 1) <= y {
        i += 1;
    }
    println!("{}", i - 1);
}

Measured memory_bytes: 4352
/* ex 4-3
    kas056 */
#include <stdio.h>

int height(int a, int b);//関数の宣言

int main(void){
    int length_1, length_2, snow;
    scanf("%d %d", &length_1, &length_2);//入力を読み取る

    snow = height(length_1,length_2);//関数（後述）を呼ぶ

    printf("%d", snow);

    return 0;
}

int height(int a,int b){//関数を作る
    int pole = 0;
    int difference = b - a;

    //雪の深さによっては二本の柱の差は変化しないことを利用する
    for (int i = 1; i < difference ; i ++){
        pole += i;//差がdifferenceとなる隣り合わせの柱のうち、低い方を求める
    }

    return (pole - a);//低い柱の本来の高さ-測定した低い方の柱=雪の深さ
}

Measured memory_bytes: 128
#include <cstdint>
#include <iostream>
#include <string>

using namespace std;

int Bit(int num, int pos)
{
    return (num & (1 << pos)) ? 1 : 0;
}

int64_t Sum(const string &str, int breaks)
{
    int64_t sum = 0;
    auto left = 0;

    for (size_t i = 0; i + 1 < str.size(); i += 1) {
        if (Bit(breaks, i) == 1) {
            sum += stol(str.substr(left, 1 + i - left));
            left = i + 1;
        }
    }
    sum += stol(str.substr(left));

    return sum;
}

int main()
{
    string str;
    getline(cin, str);

    int64_t res = 0;
    for (auto i = 0; i < (1 << (str.size() - 1)); i += 1) {
        res += Sum(str, i);
    }

    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 256
k = int(input())
import sys
c = 0
A = []
for i in range(10):
    for t in range(1, 10):
        if i == 0:
            c += 1
            anss = t
            # print(anss, c)
            if c == k:
                print(anss)
                sys.exit()
        else:
            
            for j in range(3**i):
                jj = j
                j3 = [0] * i
                for p in range(i-1,-1,-1):
                    j3[p] = jj%3-1
                    jj//=3
                # print(j3)
                ng = 0
                tt = t
                ans = [tt]
                # print(j3)
                for p in range(i):
                    tt += j3[p]
                    ans.append(tt)
                    if tt < 0 or tt >= 10:
                        ng = 1
                        break
                # print(j3, ans,ng,c)
                if ng == 0:
                    c += 1
                    anss = "".join([str(ij) for ij in ans])
                # print(anss, c)
                if c == k:
                    print(anss)
                    sys.exit()

Measured memory_bytes: 43116
N=int(input())
import bisect

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
if N==1:
  print(0)
else: 
	count=0  
	k=[1,3,6,10,15,21,28,36,45,55]
	l=factorization(N)
	#print(l)
	for i in l:
  		q=bisect.bisect(k,i[1])
  		count+=q
  
	print(count)
  
  





Measured memory_bytes: 63564
#include <iostream>

using namespace std;

int main(void){
	int n;
	string s;
	cin >> n;
	cin >> s; cin.ignore();
	int x=0;
	int c=0;
	for(int i=0; i<n; i++){
		if(s[i] == 'I'){
			c++;
		}else{
			c--;
		}
		x = max(c,x);
	}
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 256
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    x,a,b = f()

    if abs(x-a) <= abs(x -b):
        print('A')
    else:
        print('B')

solve()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#include <set>
#include <iterator>
using namespace std;
using namespace __gnu_pbds;


#define ft first
#define sd second
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define INF INT_MAX

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )

typedef tree<pll, null_type, less<pll>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;
const int N=1e5+10, M=(ll)1e6+10 ;
const int mod = 998244353  ;

// vl compute(string s){
//         vl has(s.length());
//         ll i;

//         for(i=0;i<s.length();i++){
//             if(i==0){
//                 has[i]=((s[i]-'a'+1))%mod;
//             }
//             else
//                 has[i]=(has[i-1]*p + (s[i]-'a'+1))%mod;
//         }
//         return has;
// }
vl a(N),b(N),col(N,0),vis(N,0);
ll n,m;
vl g[N];

int main(){
 ios_base::sync_with_stdio(0);
 ll i,m,k;
 cin >> m >> k;
 if(m==0){
    if(k){
      cout << -1;
      return 0;
    }
    else{
        cout << "0 0";
        return 0;
    }
 }
 else if(m==1){
    if(k)
      cout << -1;
    else
      cout << "0 1 1 0";
    return 0;
 }
 else{
   
   ll l=pow(2,m);
   if(k>=l){
      cout << -1;
      return 0;
   }
   
    for(i=0;i<l;i++){
        if(i==k)
          continue;
        else
          cout << i << " ";
    }
    cout << k << " ";
    for(i=l-1;i>=0;i--){
        if(i==k)
          continue;
        cout << i << " ";
    }
    cout << k << " ";
 }
 return 0;
}

Measured memory_bytes: 7296
using System;
class Program
{
	static void Main(string[] args)
	{
		// スペース区切りの整数の入力
		string[] input = Console.ReadLine().Split(' ');
		int a = int.Parse(input[0]);
		int b = int.Parse(input[1]);
		
        String result = a * b % 2 == 0 ? "Even" : "Odd";

        //出力
		Console.WriteLine(result);
	}
}

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

int main() {
  int n;
  cin >> n;
  bool r = false;
  for (int i = 1; i < 10; i++) {
    for (int j = 1; j < 10; j++) {
      r |= i * j == n;
    }
  }
  cout << (r ? "Yes" : "No") << endl;
}


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

int n,l[N],r[N],f[N];
char a[N],b[N];

int read(){
	int x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int main(){
	scanf(" %s %s",a,b);n=strlen(a);
	for (int i=0;i<n;i++) a[n]|=(a[i]=='1');
	for (int i=0;i<n;i++) b[n]|=(b[i]=='1');
	if (!b[n]) {printf("%d\n",-a[n]);return 0;}
	while (b[(0-l[0]+n)%n]=='0') l[0]++;
	for (int i=1;i<n;i++)
		l[i]=(b[i]=='1')?0:l[i-1]+1;
	while (b[(n-1+r[n-1])%n]=='0') r[n-1]++;
	for (int i=n-2;i>=0;i--)
		r[i]=(b[i]=='1')?0:r[i+1]+1;
	int ans=0x3fffffff;
	for (int i=0;i<n;i++){
		fill(f,f+n,0);
		int cnt=0,mx=i;
		for (int j=0;j<n;j++)
			if (a[j]!=b[(j+i)%n])
			f[l[j]]=max(f[l[j]],r[j]),cnt++;
		for (int j=n-1;j>=0;j--){
			ans=min(ans,cnt+2*(j+mx)-i);
			mx=max(mx,f[j]);
		}
	}
	for (int i=0;i<n;i++){
		fill(f,f+n,0);
		int cnt=0,mx=i;
		for (int j=0;j<n;j++)
			if (a[j]!=b[(j-i+n)%n])
			f[r[j]]=max(f[r[j]],l[j]),cnt++;
		for (int j=n-1;j>=0;j--){
			ans=min(ans,cnt+2*(j+mx)-i);
			mx=max(mx,f[j]);
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (true) {
            int a = scanner.nextInt();
            String b = scanner.next();
            int c = scanner.nextInt();
            if (b.equals("?"))
                break;
            int e = 0;
            if (b.equals("+"))
                e = a + c;
            else if (b.equals("-"))
                e = a - c;
            else if (b.equals("*"))
                e = a * c;
            else
                e = a / c;
            System.out.println(e);
 
        }
    }
}



Measured memory_bytes: 26344
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    static class DCaracalVsMonster
    {
        static void Main(string[] args)
        {
            var h = long.Parse(Console.ReadLine());
            int count = 0;
            while (h > 1)
            {
                h /= 2;
                count++;
            }

            long total = 0;
            for (int i = 0; i < count + 1; i++)
            {
                total += (long)Math.Pow(2, i);
            }

            Console.WriteLine(total);
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 11220
#include <iostream>
using namespace std;
int main()
{
	int n,AC=0,TLE=0,WA=0,RE=0;
	string test;
	cin>>n;
	for (int i=0;i<n;i++)
	{
		cin>>test;
		if (test=="AC")
			AC++;
		else if (test=="TLE")
			TLE++;
		else if (test=="WA")
			WA++;
		else if (test=="RE")
			RE++;
	}
	cout<<"AC x "<<AC<<endl;
	cout<<"WA x "<<WA<<endl;
	cout<<"TLE x "<<TLE<<endl;
	cout<<"RE x "<<RE<<endl;
}

Measured memory_bytes: 3608
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000
#define MAX 1600

typedef long long ll;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int N, M;
int x[MAX], y[MAX];

int main(void) {
    while (1) {
        cin >> N >> M;
        if (N == 0 && M == 0) break;
        x[0] = y[0] = 0;
        for (int i = 1; i <= N; i++) {
            int h;
            cin >> h;
            y[i] = y[i-1] + h;
        }
        for (int i = 1; i <= M; i++) {
            int w;
            cin >> w;
            x[i] = x[i-1] + w;
        }
        vector<int> all;
        for (int i = 0; i <= N; i++) {
            for (int j = i+1; j <= N; j++) {
                all.push_back(y[j]-y[i]);
            }
        }
        sort(all.begin(), all.end());
        int ans = 0;
        for (int i = 0; i <= M; i++) {
            for (int j = i+1; j <= M; j++) {
                int len = x[j] - x[i];
                ans += upper_bound(all.begin(), all.end(), len) - lower_bound(all.begin(), all.end(), len);
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 14608
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int D = Integer.parseInt(sc.next());

        int res = N / ((2 * D) + 1);
        if (N % ((2 * D) + 1) != 0) {
            res++;
        }

        System.out.println(res);
    }
}



Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(ll i = (ll)(a); i <= (ll)(b); i++)
#define NFOR(i,a,b) for(ll i = (ll)(a); i >= (ll)(b); --i)
#define rep(i, a) for (ll i = 0; i < a; i++)
#define endl "\n"
#define fi first
#define se second
#define MOD 1000000007
#define inf 1e12
#define pb push_back
#define Case cout<<"Case #"<<++cas<<": ";
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(v) v.begin(),v.end()

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;

#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const multiset<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}

const int maxk = 100005;
ll dp[2][maxk];

void solve() {
	ll n, k;
	cin >> n >> k;

	vl a(n);
	rep(i, n) cin >> a[i];

	rep(i, n + 1) {
		ll s = 0;
		rep(j, k + 1) {
			if (i == 0) dp[0][j] = (j == 0);
			else {
				s = (s + dp[(i + 1) % 2][j]) % MOD;
				ll lst = j - a[i-1] - 1;
				if (lst >= 0) s = (s - dp[(i+1)%2][lst] + MOD) % MOD;

				dp[i%2][j] = s;
			}
		}
	}

	cout << dp[n%2][k] << endl;
}

int main()
{
    fastio;
    ll t  = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>
int main(){
  int i,j;
  int len;
  char s[102];
  while(fgets(s,102,stdin)!=0){
    len=strlen(s);
    for(i=0;i<len;i++){
      if(s[i]=='@'){
	for(j=0;j<s[i+1]-'0';j++)
	  printf("%c",s[i+2]);
	i+=2;
      }else
	printf("%c",s[i]);
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vs vector<string>
#define pb push_back
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a;
    cin>>a;
    cout<<a+a*a+a*a*a;

    return 0;
}


Measured memory_bytes: 3576
// यथा चतुर्भिः कनकं परीक्ष्यते निघर्षणच्छेदनतापताडनैः।
// तथा चतुर्भिः पुरुषः परीक्ष्यते त्यागेन शीलेन गुणेन कर्मणा॥
#include <bits/stdc++.h>
using namespace std;
#define lld long long int
#define M 1000000007
#define fors(i,n) for(int i=0;i<n;++i)
#define fore(i,a,b) for(int i=a;i<=b;++i)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define vv std::vector<int>
#define mapii std::map<int,int>
#define mpaci std::map<char,int>
#define umapii std::unordered_map<int,int>
#define umapci std::unordered_map<char,int>
#define seti std::set<int>
#define useti std::unordered_set<int>
#define qi std::queue<int>
#define qc std::queue<char>
#define sti std::stack<int>
#define stc std::stack<char>
#define endl "\n"
#define test(i) cout<<i<<endl
#define tests(i) cout<<"i: "<<i<<endl;
#define itrt int t; cin>>t; fors(i,t)
#define itr1 int t; cin>>t;
#define ff first
#define ss second
#define pb push_back
#define vmp make_pair
#define ppb pop_back
#define sorta(a,n) sort(arr,arr+n)
#define sortv(x) sort(x.begin(),x.end())
#define all(x) x.begin(),x.end() 
#define printv(v) for(auto x: v){ cout<< x << " ";}
#define pi 3.14159265358979323846
#define setprc(x) setprecision(x)
void file(){
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
bool sortdesk(const pair<int,int> &a, const pair<int,int> &b){return a.ff>b.ff;}
bool sortdesv(const pair<int,int> &a, const pair<int,int> &b){return a.ss>b.ss;}
bool sortascv(const pair<int,int> &a, const pair<int,int> &b){return a.ss<b.ss;}
bool sortasck(const pair<int,int> &a, const pair<int,int> &b){return a.ff<b.ff;}
bool is_prime(int n){if(n==1){return false;}int i=2;while(i*i<=n){if(n%i==0){return false;}i+=1;}return true;}
int gcd(int a, int b){if (b == 0){return a;} return gcd(b, a % b);}
int cntdiv(int n){int cnt=0;for(int i=1;i<=sqrt(n);++i){if(n%i==0){if(n/i==i)++cnt;else{cnt = cnt + 2;}}}return cnt;}
lld posnegmod(lld a,lld b){//return (x%mod+mod)%mod;
long long int r = a % b;
    return r < 0 ? r + b : r;
}
// cout<<fixed<<setprecision(20)
// lld fact(lld n);
// lld nCr(lld n,lld r){return fact(n) / (fact(r) * fact(n - r));}
// lld fact(lld n){ lld res = 1; for(lld i = 2; i <= n; i++){res = res * i;}return res;} 
// const int maxi = 1e6+10;
// vector<int> v[maxi];
// vector<long long> a(maxi,0);
// void dfs(int x){
//     if(a[x]){return;}
//     a[x]=1;
//     for(int i=0;i<v[x].size();++i){
//         dfs(v[x][i]);
//     }
// }

void test_case(){
    string s;
    cin>>s;
    if(s=="ABC"){
        cout<<"ARC";
        return;
    }
    cout<<"ABC";
}

int main(){
    fastio;
    file();
    int T=1;
    // int T;
    // cin>>T;
    for(int nr=1;nr<=T;++nr) {
        // cout<<"Case #"<<nr<<": ";
        test_case();
    }
}


Measured memory_bytes: 3624
import itertools
n = int(input())
sp = str(list(map(int,input().split())))
sq = str(list(map(int,input().split())))

d = [i+1 for i in range(n)]

p = list(itertools.permutations(d))


order_dict = {}
for i in range(len(p)):
    order_dict[str(p[i])] = i

sp_str = sp.replace('[', '(').replace(']',')')
sq_str = sq.replace('[', '(').replace(']',')')

print(abs(order_dict[sq_str] - order_dict[sp_str]))

Measured memory_bytes: 14024
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;


int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N, W; cin >> N >> W;
    vi v(N), w(N);
    REP(i, N) cin >> v[i] >> w[i];

    vll dp(W + 1, -1);
    dp[0] = 0;

    REP(i, N) {
        REP(j, W) {
            if (dp[j] > -1 && j + w[i] <= W) dp[j + w[i]] = max(dp[j] + v[i], dp[j + w[i]]);
        }
    }

    ll ans = 0;
    REP(i, W + 1) ans = max(ans, dp[i]);
    print(ans);

}


Measured memory_bytes: 3264
#include <bits/stdc++.h>
using namespace std;
 
int main() {

	int N,M=0,R=0;
	cin >> N;
	vector<int> D(N);
	for (int i=0; i<N; i++){
		cin >> D.at(i);
	}

	sort(D.begin(),D.end());
	
	for (int i=0; i<N; i++){
		if (M < D.at(i)) {
			R++;
			M = D.at(i);
		}
	}
		
	cout << R << endl;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <climits>
#include <string>

using namespace std;

int main() {
	int n, i, h;
	string s;
	bool flag;

	cin >> n >> s;

	flag = false;
	if (n % 2 == 0) {
		h = n / 2;
		flag = true;
		for (i = 0; i < h; i++) {
			if (s[i] != s[h + i]) {
				flag = false;
				break;
			}
		}
	}
	if (flag) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

}

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

L = [int(input()) for i in range(N)]

# L本の竹を、A,B,C,0(使わない)に振り分ける全探索 4^N = 約60000通り

ans = 10 ** 10
import itertools
for prod in itertools.product(range(4), repeat = N):
  bamboo = [0] * 4
  mp = 0
  for i in range(len(prod)):
    if prod[i] == 0:
      continue
    if bamboo[prod[i]] != 0:
      mp += 10
    bamboo[prod[i]] += L[i]
  if 0 in bamboo[1:]:
    continue
  mp += abs(A - bamboo[1]) + abs(B - bamboo[2]) + abs(C - bamboo[3])
  if ans > mp:
    ans = mp
    
print(ans)

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

int main() {
    string s, t;
    cin>>s >>t;
    int x=s.size();
    if(s==t.substr(0,x)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

int main() {
	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;

	if (A + B < 2 * C) cout << A * X + B * Y;
	else {
		int ans = 0;
		int min = X < Y ? X : Y;
		ans += 2 * C * min;
		X -= min;
		Y -= min;
		if (X > 0) ans += A < 2 * C ? A * X : 2 * C * X;
		if (Y > 0) ans += B < 2 * C ? B * Y : 2 * C * Y;
		cout << ans;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 102

int main(){
  int a[N][N];
  int n,i,j,u,k,v;

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

  for(i=1;i<=n;i++){
    scanf("%d%d",&u,&k);
    for(j=1;j<=k;j++){
      scanf("%d",&v);
      a[u][v]=1;
    }
  }

  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      if(j!=1) printf(" ");
      printf("%d",a[i][j]);
    }
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2100
#include <iostream>
#include <bits/stdc++.h>
#include<string>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <fstream>
#include <vector>

#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define SPACE " "
#define nLINE '\n'
#define ss second
#define ff first
//scanf("%d",&x) ,s.insert(x);
using namespace std;

ll GCD(ll a, ll b) {
	//Euclidian
	if (!b) return a;
	else return GCD(b, a % b);
}
const ll MAX = 51;
bool prime[MAX];
void sieve() {
	for (int p = 2; p * p <= MAX; p++)
		if (prime[p] == false)
			for (int i = p * 2; i <= MAX; i += p)
				prime[i] = true;
}

int comb(int a, int b)
{
	if (a < b) return 0;
	if (a == b) return 1;
	if (b == 0) return 1;
	return comb(a - 1, b) + comb(a - 1, b - 1);
}
int x[30];
long long int y[30];
long long int func(int s, int t)
{
	if (t == 0) return 1;
	if (s == 0) return 1;

	if (x[s] == 0) return func(s - 1, t);
	else
	{
		long long int sum = 0;
		for (int i = 0;i <= t;i++) sum += comb(s - 1, i) * y[i];

		long long int s1 = sum;

		sum = 0;
		for (int i = 0;i <= t - 1;i++) sum += comb(s - 1, i) * y[i];
		long long int s2 = (x[s] - 1) * sum;
		long long int s3 = func(s - 1, t - 1);
		return s1 + s2 + s3;
	}
}



int dp[13][1 << 13];
double arr[20][20];
int n;
int dvds[13],svs[13];
vector<double> sssp(int);
vector<double> minDis[20];
int Size;

double solve(int current, int mask) {
    if(mask == ((1 << Size) - 1)) return -arr[dvds[current]][0];

    if(dp[current][mask] != -1)
        return dp[current][mask];


    double Max = -arr[dvds[current]][0];
    for(int i= 0; i< Size; i++)
        if((mask & (1 << i)) == 0)
            Max = max(Max, svs[i] - arr[dvds[current]][dvds[i]]+ solve(i, mask | (1 << i)));

    return dp[current][mask]= Max;
}

int nextMin(int,int);

int main() {
	ll t;
	ll AC=0,WA=0,TLE=0,RE=0;
	cin >> t;
	while(t--){
        string s;
        cin >>s;
        if(s=="AC") AC++;
        else if(s=="WA") WA++;
        else if(s=="TLE") TLE++;
        else if(s=="RE") RE++;
	}
	cout << "AC x " << AC << nLINE <<"WA x " << WA << nLINE << "TLE x " << TLE << nLINE << "RE x " << RE << nLINE;
}

bool used[20];
vector<double> sssp(int src) {
	vector<double> disSource(n);
	fill(disSource.begin(), disSource.end(), INT_MAX);
	disSource[src] = 0;
	int curr = src;
	memset(used, false, sizeof used);
	used[curr] = true;
	while (curr != -1) {
		for (int j = 0;j < n;j++) {
			if (arr[curr][j] != -1) {
				if (disSource[j] == INT_MAX) disSource[j] = arr[curr][j] + disSource[curr];
				else disSource[j] = std::min(disSource[j], disSource[curr] + arr[curr][j]);
			}
		}
		used[curr] = true;
		curr = nextMin(curr,src);
	}
	return disSource;
}

int nextMin(int curr,int src) {
	int indx = -1;
	double Min = 1e9;
	for (int i = 0;i < n;i++) {
		if (arr[curr][i]!=-1 && arr[curr][i] <= Min && used[i] == false) {
			Min = arr[curr][i];
			indx = i;
		}
	}
	if (indx == -1){
        for(int i=0;i<n;i++)
            if(arr[src][i]!=-1 && arr[curr][i] <= Min && used[i]== false)
                indx = i , Min = arr[curr][i];
	}
	if (indx == -1) return -1;
	return indx;
}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
char s[N];
int main(){
	scanf("%s",s);
	int n=strlen(s);
	if(s[0]==s[n-1]) n--;
	puts(n&1?"First":"Second");
	return 0;
}

Measured memory_bytes: 3816
from operator import mul
from functools import reduce
def PrimeDecomp(N,ConcFlag):
    if ConcFlag:
        if N<=1:
            return [1],1
        else:
            I = 2
            PrimeDec = []
            DivCount = 1
            while I*I<=N:
                Cnt = 0
                while N%I==0:
                    N //= I
                    PrimeDec.append(I)
                DivCount *= (Cnt+1)
                I += 1
            if N>=2:
                PrimeDec.append(N)
                DivCount *= 2
            return PrimeDec,DivCount        
    else:
        if N<=1:
            return [1],[1],1
        else:
            I = 2
            PrimeDec = []
            PrimeCnt = []
            DivCount = 1
            while I*I<=N:
                Cnt = 0
                while N%I==0:
                    N //= I
                    Cnt += 1
                if Cnt>=1:
                    PrimeDec.append(I)
                    PrimeCnt.append(Cnt)
                    DivCount *= (Cnt+1)
                I += 1
            if N>=2:
                PrimeDec.append(N)
                PrimeCnt.append(1)
                DivCount *= 2
            return PrimeDec,PrimeCnt,DivCount

def DivisorFactorial(N,FactDec,FactCnt,MemoFlag):
    if MemoFlag:
        if N<=1:
            FDivCnt = 1
            return FactDec,FactCnt,FDivCnt
        else:
            PrimeDec,PrimeCnt,_ = PrimeDecomp(N,False)
            for TP in range(0,len(PrimeDec)):
                if PrimeDec[TP] in set(FactDec):
                    FactCnt[FactDec.index(PrimeDec[TP])] += PrimeCnt[TP]
                else:
                    FactDec.append(PrimeDec[TP])
                    FactCnt.append(PrimeCnt[TP])
            FDivCnt = reduce(mul,[(T+1) for T in FactCnt])
            return FactDec,FactCnt,FDivCnt
    else:
        if N<=1:
            FDivCnt = 1
            return FactDec,FactCnt,FDivCnt
        else:
            for TN in range(2,N+1): 
                PrimeDec,PrimeCnt,_ = PrimeDecomp(TN,False)
                for TP in range(0,len(PrimeDec)):
                    if PrimeDec[TP] in set(FactDec):
                        FactCnt[FactDec.index(PrimeDec[TP])] += PrimeCnt[TP]
                    else:
                        FactDec.append(PrimeDec[TP])
                        FactCnt.append(PrimeCnt[TP])
            FDivCnt = reduce(mul,[(T+1) for T in FactCnt])
            return FactDec,FactCnt,FDivCnt
          
N = int(input())
FactDec,FactCnt,FDivCnt = DivisorFactorial(N,[],[],False)
print(FDivCnt%(10**9+7))

Measured memory_bytes: 9476
/*
    Mbak Sana Dong
    Mbak Chaeyoung Dong
*/
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int arr[1000010], cnt[1000010];
bool prime[1000010];
vector<int> v[1000010];
void sieve()
{
    int i,j;
    for(i=2;i<=1000000;i++) {
        if(!prime[i]) {
            v[i].push_back(i);
            for(j=i*2;j<=1000000;j+=i) {
                prime[j]=1;
                v[j].push_back(i);
            }
        }
    }
}
int main()
{
    int n,i,j,k,x,y,ans,curr,temp,m;
    int tc;
    string pc = "pairwise coprime", sc = "setwise coprime", nc = "not coprime";
    cin >> n;
    int gcd = 0;
    sieve();
    for(i=1;i<=n;i++) {
        scanf("%d",&arr[i]);
        gcd = __gcd(gcd, arr[i]);
        for(auto x : v[arr[i]]) cnt[x]++;
    }
    bool can = 1;
    for(i=2;i<=1000000;i++) {
        if(cnt[i] > 1) can = 0;
    }
    if(can) cout << pc;
    else if(gcd==1) cout << sc;
    else cout << nc;
    cout << endl;
    return 0;
}


Measured memory_bytes: 67820
n, k = map( int, input().split() )
vl = map( int, input().split() )
vl = list(vl)

ans = 0
for sublen in range(1, min(k+1,n+1)):

    for left in range(0, sublen+1):
        right = sublen - left
        subq = vl[:left] + vl[n-right:]
        subq.sort()

        rlen_max = min(k-sublen, len(subq)-1 )
        rlenf = 0
        for rlen in range(rlen_max-1, -1, -1):
            if subq[rlen] <= 0:
                rlenf = rlen + 1
                break

        ans = max(ans, sum(subq[rlenf:]))


print(ans)

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
"""
Created on Sun May 10 20:50:56 2020
"""

import sys
#import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

#N = int(input())
N,K = map(int,input().split())
A = list(map(int,input().split()))

city = [False for i in range(N)]
city[1-1] =True
now = 1

counta1 = 0
while True:
    counta1 += 1
    prev = now
    now = A[now-1]
#    print(prev,now,counta1)
    if city[now-1]:
        break
    elif counta1 == K:
        print(now)
        sys.exit()
    else:
        city[now-1] = True

counta = 1
rout = []
rout.append(now)
while now != prev:
    now = A[now-1]
    rout.append(now)
    counta +=1
#    print(now,rout,counta)

ans = rout[(K-counta1) % counta]
print(ans)


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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

vector<int> node[100000];

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, M; cin >> N >> M;
    int H[N]; rep(i, N) cin >> H[i];
    rep(i, M){
        int a, b; cin >> a >> b;
        a--; b--;
        node[a].push_back(b);
        node[b].push_back(a);
    }
    int ans = 0;
    rep(i, N){
        bool ok = true;
        rep(j, node[i].size()){
            int to = node[i][j];
            if(H[i] <= H[to]) ok = false;
        }
        if(ok) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9140
#python3
from collections import Counter
def C2(x):
    return x*(x-1)//2

def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    d = Counter(a) 
    pans = 0
    for v in d.values():
        pans += C2(v)

    for k in range(n):
        p = pans
        val = d[a[k]]
        p = p - C2(val) + C2(val-1)
        print(p)
main()

Measured memory_bytes: 26772
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] S = sc.nextLine().split(" ");
        long A = Long.parseLong(S[0]);
        long B = Long.parseLong(S[1]);
        sc.close();

        long temp = 0;
        for(int i = 1; i <= 1262; i++){
            long a = (long) (i * 0.08);
            if(a != A){
                continue;
            }
            long b = (long) (i * 0.1);
            if(b == B){
                temp = i;
                break;
            }
        }

        if(temp == 0){
            System.out.println("-1");
        }else{
            System.out.println(temp);
        }
    }

}


Measured memory_bytes: 23764
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();

        //        for (int i = 1; i <= n; i++) {
        //
        //        }

        sc.close();

        if (6 <= a && a <= 12) {
            b /= 2;
        } else if (a <= 5) {
            b = 0;
        }

        System.out.println(b);

    }
}

Measured memory_bytes: 21972