akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdlib.h>
#include<set>
#include<math.h>

using namespace std;

int main(void)
{
    int n,m;
    cin>>n>>m;
    
    vector<vector<int> > s(m,vector<int>(0));
    
    for(int i=0;i<m;i++){
        int k;
        cin>>k;
        for(int j=0;j<k;j++){
            int num;
            cin>>num;
            s[i].push_back(num-1);
        }
    }
    int p[m];
    for(int i=0;i<m;i++){
        cin>>p[i];
    }
    
    int arr[n];
    int count=0;

    for(int j=0;j<pow(2,n);j++){
        int num2=j;
        for(int k=0;k<n;k++){
            if(num2>0){
                arr[k]=num2%2;
                num2/=2;
            }
            else{
                arr[k]=0;
            }
        }
        int break_flag=0;
        
        for(int o=0;o<m;o++){
            int e=0;
            
            for(int z=0;z<s[o].size();z++){
                if(arr[s[o][z]]==1){
                    e++;
                }
            }
            if(e%2!=p[o]){
                break_flag=1;
                break;
            }
        }
        if(break_flag==0){
            count++;
        }
       
    }
    cout<<count<<endl;
    
}


Measured memory_bytes: 256
char*p,S[9999];c[99],t;main(j){for(gets(S),gets(p=S);*p;c[*p++]++)for(j=2e3;j--;)t-=(*p^p[j]^p[j+j])>86;printf("%ld",1L*c[66]*c[71]*c[82]+t);}

Measured memory_bytes: 1628
#include <bits/stdc++.h>
#define mod 998244353
#define db(a) cout << a << endl
#define db2(a,b) cout << a << " " << b << endl
#define dbp(a) cout << a.first << " " << a.second << endl
#define adb(a) for(auto i:a) cout << i << " "; cout << endl
#define adb2(a) for(auto i:a) cout << i.first << " " << i.second << endl;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define N 500010
#define P 2019
using namespace std;

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

    long long n = s.length(), suff[n+1] = {0}, freq[P+1] = {0}, pow10 = 1, i;
    freq[0]++;

    for(i=n-1;i>=0;i--)
    {
        suff[i] = (((s[i]-'0')*pow10)%P + suff[i+1])%P;
        pow10 = (pow10*10)%P;
        freq[suff[i]]++;
    }

    long long ans = 0;
    for(i=0;i<=P;i++) ans += (freq[i]*(freq[i]-1))/2;

    cout << ans << endl;
}

Measured memory_bytes: 5332
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define opr iterator
typedef long long ll;
using namespace std;
int main()
{
	int al,ar;
	int n,m;
	int l[100001],r[100001];
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		cin>>l[i]>>r[i];	
	}
	al=l[1];
	ar=r[1];
	for(int i=2;i<=m;i++)
	{
		al=max(al,l[i]);
		ar=min(ar,r[i]);
		if(al>ar)
		{
			cout<<0<<endl;
			exit(0);
		}
	}
	cout<<ar-al+1<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <queue>

using namespace std;

int n, k;
priority_queue<int> priorityQueue;

int main(int argc, char** argv)
{
    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; ++i)
    {
        int wi;
        scanf("%d", &wi);
        priorityQueue.emplace(wi);
    }
    if (k >= n)
    {
        printf("%d", 0);
    }
    else
    {
        for (int i = 0; i < k; ++i)
        {
            priorityQueue.pop();
        }
        unsigned long long result = 0;
        while (!priorityQueue.empty())
        {
            result += priorityQueue.top();
            priorityQueue.pop();
        }
        printf("%lld", result);
    }
    return 0;
}

Measured memory_bytes: 1400
import java.util.Scanner;

public class Main{
	public static void main(String args[]){

		//sc?????????????????????????????¨??????????????£?¨?
		Scanner sc = new Scanner(System.in);
		long listA [][];
		long listB [][];

		//??°???nml???????????????
		int n = sc.nextInt();
		int m = sc.nextInt();
		int l = sc.nextInt();

		//?????????A,B???????????¨??¨?????????????????????????????????
		listA = new long[n][m];
		listB = new long[m][l];

		//?????????A???????????????
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				listA[i][j] = sc.nextInt();
			}
		}

		//?????????B???????????????
		for(int i = 0; i < m; i++){
			for(int j = 0; j < l; j++){
				listB[i][j] = sc.nextInt();
			}
		}

		//
		for(int i = 0; i < n ; i++){
			for(int j = 0; j < l; j++){
				long ans = 0;
				for(int k = 0; k < m; k++){

					ans += listA[i][k] * listB[k][j];
				}
				System.out.print(ans);
				if(j+1 != l){
					System.out.print(" ");
				}
			}
			System.out.println("");
		}
		sc.close();
	}
}

Measured memory_bytes: 52348
using System;
class test
{
    static void Main(string[] args)
    {
        int a = int.Parse(Console.ReadLine());
        Console.Write(a + ":");
        while (a % 2 == 0)
        {
            a /= 2;
            Console.Write(" 2");
        }
        for(int i = 3; i * i <= a; i += 2)
        {
            while (a % i == 0)
            {
                a /= i;
                Console.Write(" " + i);
            }
        }
        if (a != 1)
        {
            Console.WriteLine(" " + a);
        }
        else
        {
            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 19956
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		boolean ans = true;
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		ArrayList<String> list = new ArrayList<>();
		for (int i=0; i<n; i++){
			String str = scanner.next();
			if (ans) {
				if (list.contains(str)) {
					ans = false;
				}else {
					if (list.isEmpty()){
						list.add(str);
					}else {
						String last = list.get(list.size()-1);
						if (str.startsWith(last.substring(last.length()-1))){
							list.add(str);
						}else {
							ans = false;
						}
					}
				}
			}
		}
		if (ans) System.out.println("Yes");
		else System.out.println("No");
	}
}

Measured memory_bytes: 23252
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
int a,b,c; 
int main(){
	cin>>a>>b>>c;
	cout<<min(b/a,c);
	return 0;
}

Measured memory_bytes: 256
import math


def resolve():
    import sys
    input = sys.stdin.readline
    row1 = [int(x) for x in input().rstrip().split(" ")]
    n = row1[0]
    c = row1[2]

    ans = 0
    b_list = [int(x) for x in input().rstrip().split(" ")]
    for _ in range(n):
        a_list = [int(x) for x in input().rstrip().split(" ")]

        if sum([a*b for a, b in zip(a_list, b_list)]) + c > 0:
            ans += 1

    print(ans)





if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9096
cmd = list( map( int, input( ).split( )))
cnt5 = 0
cnt7 = 0
for i in range( len( cmd)):
  if cmd[i] == 5:
    cnt5 +=1
  elif cmd[ i] == 7:
    cnt7 += 1
if cnt5 == 2 and cnt7 == 1:
  print( "YES")
else:
  print( "NO")


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

int main() {
	int n1,n2;
	cin>>n1>>n2;
	if(n1<n2){
		for(int i=0;i<n2;i++) cout<<n1;
	}else{
		for(int i=0;i<n1;i++) cout<<n2;
	}
	cout<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int inf=1e7+9;
int main()
{
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
	int m,n,k;
	cin>>m>>n>>k;
	cout<<(m-n)%k<<endl; 
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int time = sc.nextInt();
		
		int c_min = 1001;
		
		for(int i = 0 ; i < n ; i++) {
			
			int c = sc.nextInt();
			int t = sc.nextInt();
			
			if(t <= time ){
				if(c < c_min){
					c_min = c;
				}
			}
			
		}
		
		if(c_min >= 1001) {
			System.out.println("TLE");
		} else {
			System.out.println(c_min);
		}
	}
}


Measured memory_bytes: 23508
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const double eps = 1e-9;

const int N = 200000;
int use[N];

const int D = 86400;

int main(){
    int n,L;
    while(scanf(" %d %d", &n, &L),n){
        fill(use,use+N,0);

        int min_s = N;
        rep(i,n){
            int s,t,u;
            scanf(" %d %d %d", &s, &t, &u);
            min_s = min(min_s, s);
            use[s] += u;
            use[t] -= u;
        }

        rep(i,N-1) use[i+1] += use[i];

        auto check = [&](double m){
            double x = L;

            vector<int> full(D);
            rep(i,D){
                double d = m-use[i];
                x += d;
                if(x>L){
                    x = L;
                    ++full[i];
                }
                if(x<-eps) return false;
            }

            rep(i,D){
                double d = m-use[i];
                x += d;
                if(x>L){
                    x = L;
                    if(full[i]) return true;
                }
                if(x<-eps) return false;
            }
            return false;
        };

        double l=0, r=1000000;
        rep(loop,50){
            double mid = (l+r)/2;
            if(check(mid)) r = mid;
            else l = mid;
        }
        printf("%.10f\n", r);
    }
    return 0;
}



Measured memory_bytes: 4196
#include<bits/stdc++.h>
#define fo(i,w,n) for(int i=(int) w;i<(int) n;i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int l,r,ans=1e9;
	cin>>l>>r;
	fo(i,l,min(l+2020,r+1)) fo(j,l,min(l+4040,r+1)) if(i<j)ans=min(ans,(i%2019)*(j%2019)%2019);
	cout<<ans<<endl;
	return 0;
}


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

int main(void){
    string s;
    while(getline(cin, s)){
        rep(i, s.size()) {
            if(s[i]>='a' && s[i]<='z') s[i] +='A'-'a';
        }
        cout << s << endl;
    }
}

Measured memory_bytes: 1172
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args){

		solve_abcPpc_c();
	}
  
  	public static void solve_abcPpc_c(){

		Scanner sc = new Scanner(System.in);
		String ans = "No";
		
		/*
		double a = Math.sqrt((double)sc.nextLong());
		double b = Math.sqrt((double)sc.nextLong());
		double c = Math.sqrt((double)sc.nextLong());
		
		if(c - a - b > 0){
			ans = "Yes";
		}
		*/
		
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		
		long d = c - a - b;
		
		if((d > 0) && (d * d - 4 * a * b > 0)){
			ans = "Yes";
		}
		
		System.out.println(ans);

		sc.close();

	}
}

Measured memory_bytes: 22612
N, K = [int(x) for x in input().split()]
dislikes = [False] * 10
dislike_nums = [int(x) for x in input().split()]
for x in dislike_nums:
    dislikes[x] = True

for n in range(N, N * 10):
    found = False
    for x in str(n):
        if dislikes[int(x)]:
            found = True
            break
    if not found:
        break
print(n)

Measured memory_bytes: 73616
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#define INF (long)1e9
const int MOD = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	while(cin >> n >> m, n | m)
	{
		vector<P> vec;
		bool flag[m + 1];
		memset(flag, false, sizeof(flag));
		int a, b;
		for(int i = 0; i < n; i++)
		{
			cin >> a >> b;
			vec.push_back(P(b, a));
		}
		sort(vec.begin(), vec.end());
		reverse(vec.begin(), vec.end());
		int ans = 0;
		for(int i = 0; i < n; i++)
		{
			if(flag[vec[i].second] == false)
			{
				flag[vec[i].second] = true;
				ans += vec[i].first;
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3228
// Coins
// * frank_c1
// * 2017 / 11 / 14
 
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
 
const int maxn = (int)(1e5) + 5;
pii a[maxn];
int x, y, z, n;
 
inline bool chk(pii u, pii v) {
	return u.first - u.second > v.first - v.second;
}
 
multiset<int> X, Y, Ys;
int cntX, cntY;
LL sum;
 
void Ypop(int w) {
	if (Ys.find(w) != Ys.end()) Ys.erase(Ys.find(w)); 
	else {
		sum -= w; Y.erase(Y.find(w)); 
		w = *Ys.rbegin(); Y.insert(w); sum += w;
		Ys.erase(Ys.find(w));
	}
}
 
void Xpush(int w) {
	if (cntX >= x) {
		if (w > *X.begin()) {
			sum -= *X.begin();
 			X.erase(X.begin()); 
			X.insert(w); sum += w;
		}
	} else X.insert(w), ++cntX, sum += w;
}
 
void Ypush(int w) {
	if (cntY >= y) {
		if (w > *Y.begin()) {
			sum -= *Y.begin();
			Ys.insert(*Y.begin());
			Y.erase(Y.begin());
			Y.insert(w); sum += w;
		} else Ys.insert(w);
	} else Y.insert(w), ++cntY, sum += w; 
}
 
int main() {
	scanf("%d%d%d", &x, &y, &z);
	n = x + y + z;
	LL now = 0, ret = 0;
	for (int i = 1; i <= n; ++i) {
		int w; scanf("%d%d%d", &a[i].first, &a[i].second, &w); 
		a[i].first -= w; a[i].second -= w; now += w; Ypush(a[i].second);
	}
	sort(a + 1, a + n + 1, chk);
	for (int i = 1; i <= n - y; ++i) {
		Xpush(a[i].first); Ypop(a[i].second); if (i >= x) ret = max(ret, sum + now);
	}
	return printf("%lld\n", ret), 0;
}

Measured memory_bytes: 7808
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }




int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N; cin >> N; vl A(N+1); rep(i, N) cin >> A[i+1];
    vl B(N+1, 0); ll cnt = 0;
    for (ll i = N; i >= 1; i--) {
        ll now = i;
        ll sum = 0;
        for(ll k = 1; k*now <= N; k++){
            sum += B[k*now];
        }
        if(sum%2 != A[i]){
            B[i] = 1;
            cnt++;
        }
    }
    
    cout << cnt << endstr;
    FOR(i, 1, N+1){
        if(B[i] == 1){
            cout << i << endstr;
        }
    }
    return 0;
}


Measured memory_bytes: 3968
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <functional>
using namespace std;


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int cnt = 0;
    for (int i = 0; i <= a; i++) {
        for (int j = 0; j <= b; j++) {
            for (int k = 0; k <= c; k++) {
                if (x == 500 * i + 100 * j + 50 * k) {
                    cnt++;
                }
            }
        }
    }
    cout << cnt << endl;
	return 0;
}

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

int main() {
	int H, W; cin >> H >> W;
    char S[101][101];
	int A[101];
	int B[101];
	rep(i,101){
		A[i] = 0;
		B[i] = 0;
	}
	rep(i,H){
		rep(j,W){
			cin >> S[i][j];
			if (S[i][j] == '#') {
				A[i] = 1;
				B[j] = 1;
			}
		}
	}
	rep(i,H){
		if (A[i]) {
			rep(j,W){
				if (B[j]) cout << S[i][j];
			}
			cout << endl;
		}
	}
	return 0;
}

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

int main(){
  string s;
  cin >> s;
  
  int n = s.length();
  int a = (n - 1) / 2 - 1;
  int b = (n + 3) / 2 - 1;
  
  for(int i = 0; i < (n - 1)/2; i++){
    if(s[i] != s[a-i] || s[b+i] != s[n-1-i] || s[i] != s[n-1-i]){
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout << "Yes" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
const int N=100005,M=1000;
typedef long long ll;
ll a[N],res=0;
int ans[M][M],cnt[M];
int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >>n;
	int tmp=sqrt(2*n);
	if(tmp*(tmp+1)!=2*n)
	{
		cout <<"No"<<endl;
		return 0;
	}
	else cout <<"Yes"<<endl;
	int k=tmp+1;
	cout <<k<<endl;
	int tmp1=0;
	for(int i=1;i<=k;i++)
	{
		for(int j=i+1;j<=k;j++)
		{
			ans[i][++cnt[i]]=++tmp1;
			ans[j][++cnt[j]]=tmp1;
		}
	}
	for(int i=1;i<=k;i++)
	{
		cout <<cnt[i];
		for(int j=1;j<=cnt[i];j++)cout <<' '<<ans[i][j];
		cout <<endl;
	}
	return 0;
}


Measured memory_bytes: 3200
// g++ -std=c++17 -O2 -Wall C.cpp -o C -D _DEBUG

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

int main() {
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false); 
    cin.tie(NULL);
    
    int n;
    cin >> n;
    vector<int> dp(n + 1);
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n / i; j++) {
            dp[i * j]++;
        }
    }
    int ans = 0;
    for (int i = 1; i < n; i++) {
        ans += dp[i];
    }
    cout << ans;
}

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

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

int main()
{
  long long n,m;cin>>n>>m;
  vector<long long> a(n);
  int i;
  for(i=0;i<n;i++)cin>>a.at(i);
  for(i=0;i<n;i++)a.at(i)/=2;
  long long now=a.at(0);
  long long know;
  for(i=1;i<n;i++)
  {
    know=gcd(now,a.at(i));
    now=now/know*a.at(i);
    if(now>m)break;
  }
  vector<long long> nums(0);
  sort(a.begin(),a.end());
  nums.emplace_back(a.at(0));
  for(i=1;i<n;i++)if(a.at(i-1)!=a.at(i))nums.emplace_back(a.at(i));
  long long sz=nums.size();
  for(i=0;i<sz;i++)
  {
    while(nums.at(i)%2==0)nums.at(i)/=2;
  }
  sort(nums.begin(),nums.end());
  bool ch=false;
  for(i=1;i<sz;i++)if(nums.at(i-1)==nums.at(i))ch=true;
  if(now>m||ch)cout<<0<<endl;
  else
  {
    long long ks=m/now;
    cout<<(ks+1)/2<<endl;
  }
}

Measured memory_bytes: 2168
import math
def mon(h, n, k):
  if h > 1:
    h = math.floor(h / 2)
    k += n
    n *= 2
    return mon(h, n, k)
  elif h == 1:
    k += n
    return k
h = int(input())
n = 1
k = 0
print(mon(h, n, k))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef  long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<vector<int> > vvi;
#define clr(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define frpn(x) freopen(#x ".in","r",stdin);freopen(#x ".out","w",stdout);
#define all(a) a.begin(), a.end()
#define mkp make_pair
#define forn(i, n) for(int i=0; i<(int)(n); ++i)
#define forab(i, a, b) for(int i=(int)(a); i<=(int)(b); ++i)
#define fornd(i, n) for(int i=(int)(n); i>=0; --i)

const int INF = (int)1e6+5;
const int NAX = (int)3e5+5;
const int MOD = (int)1e9+7;

template <class T>
inline void rem(T &n){
   n = (-MOD <= n && n <= MOD) ? n : n%MOD ;
  if(n < 0) n += MOD; 
}
//modular inverse
//inv(a,m) - inverse of a mod m
template <class T>
inline T inv(T a, T m){
 return 1<a ? m - inv(m%a, a)*m/a : 1;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int m, d; cin >> m >> d;
    int res = 0;
    forab(i, 1, m) {
      forab(j, 1, d) {
        string p = to_string(j);
        if(p[0] >= '2' && p[1] >= '2' && (p[0]-'0')*(p[1]-'0') == i) {
          ++res;  
        }
      }
    }
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second) return a.second < b.second;
    else return a.first < b.first;
}
std::uint32_t euclidean_gcd(std::uint32_t a, std::uint32_t b){return b != 0 ? euclidean_gcd(b, a % b) : a;}
const string YES = "YES";
const string NO = "NO";

string dict[4] = {"remaerd","resare", "esare", "maerd"};

void solve(std::string S){
    // auto it = S.begin();
    int it = 0;
    reverse(ALL(S));
    do{
        debug(it)
        bool found = false;
        rep(i, 4){
            if(S.find(dict[i], it)==it){
                found = true;
                it+=dict[i].length();
                break;
            }
        }
        if(!found){cout<<"NO"<<endl;return;}
    }while(it < S.length());
    cout<<"YES"<<endl;return;
}
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 512
from collections import defaultdict,deque
H, W = map(int,input().split())
MAP = []
for _ in range(H):
    MAP.append(list(map(str,input())))

move = [[0,1],[0,-1],[1,0],[-1,0]]

def bfs(s):
    MAX = 0
    stack = deque([])
    stack.append(tuple(s))
    depth =dict()
    depth[tuple(s)] = 0
    goal = s
    while stack:
        v = stack.popleft()
        for m in move:
            a = tuple([v[0]+m[0], v[1] + m[1]])
            if a[0] < H and a[0] >=  0 and a[1] < W and a[1] >= 0:
                if MAP[a[0]][a[1]] == '.' and not a in depth:
                    stack.append(a)
                    depth[a] = depth[v] + 1

    for k,d in depth.items():
        if MAX < d:
            MAX = d
            goal = k

    return MAX, goal


for r in range(0,H):
    if "." in MAP[r]:
        start = [r, MAP[r].index(".")]

MAX, goal = bfs(tuple(start))
MAX, _ = bfs(tuple(goal))
print(MAX)
exit()


Measured memory_bytes: 3444
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<deque>
#include<vector>
#include<utility>
#include<algorithm>

using namespace std;

#define LL long long

int n;

int main() {
	cin >> n;
	cout << (n - 2) * 180 << endl;

	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#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(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;

int main(){
    int n;cin>>n;
    vstr s(n);
    rep(i,n)cin>>s[i];
    int m;cin>>m;
    vstr t(m);
    rep(i,m)cin>>t[i];
    map<string,int> count;
    rep(i,n)count[s[i]]++;
    rep(i,m)count[t[i]]--;
    int M=0;
    rep(i,n)M=max(M,count[s[i]]);
    cout<<M<<endl;
}

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

int main()
{
	long long n,a,b;
    cin>>n>>a>>b;
    long long prev=n/(a+b),rem=n%(a+b);
    if(rem>a)
    {
        rem=rem-a;
    }
    else
    {
        rem=0;
    }
    cout<<n-(prev*b+rem)<<endl;
    
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long ans;
int main()
{
	int n,m;
	vector<pair<int,int> > v;
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		int a;
		cin>>a;
		v.push_back(make_pair(a,1));
	}
	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		  v.push_back(make_pair(y,x));
	}
	sort(v.rbegin(),v.rend());
	int i=0;
	while(n)
	{
		long long res=min(n,v[i].second);
		ans+=res*v[i].first;
		n-=res;
		i++;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 2420
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#define INF 0x3f3f3f3f
#define lowbit(x) x & -x
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int N=2e5+5;
int a[N],n,k;

int check(int x){
    int cnt=0;
    for(int i=1;i<=n;i++){
        cnt+=a[i]/x-1;
        if(a[i]%x)
            ++cnt;
    }
    return cnt;
}

int main(){
#ifdef Mizp
    freopen("in.txt","r",stdin);
#endif
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    int l=1,r=1e9,ans;
    while(l<=r){
        int mid=(l+r)>>1;
        if(check(mid)<=k){
            r=mid-1;
            ans=mid;
        }else{
            l=mid+1;
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 4440
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pll pair<ll,ll>
#define sll set<ll>
#define msll multiset<ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define vpl vector<pll>
#define gll greater<ll>
#define gpl greater<pll>
#define spl set<pll>
#define mspl multiset<pll>
#define lb lower_bound
#define bp __builtin_popcount
#define ub upper_bound
#define prq priority_queue
#define mp make_pair
#define pb push_back
#define mem(x,y) memset(x, y, sizeof x)
#define endl "\n"
#define sz(x) (ll)x.size()
#define sqr(x) x*x
#define rapido ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef int ll;
typedef long double ld;
ll mx=INT_MAX;
ll mn=INT_MIN;
ll MOD=1e9+7;
const ll maxs=1e5+10;
ll max2d=1e3+3;
// ll INF = 1e18;
const ll lg=22; 

void code_idhr_h(){
    ll N; cin>>N;
    ll A[N+1]; int frq[1000005]; mem(frq , 0);
    for(ll i=1; i<=N; i++){
        cin>>A[i];
        frq[A[i]]++;
    }
    if(frq[1]){
        if(frq[1]==1) cout<<1;
        else cout<<0;
        return;
    }
    ll ans = 0;
    for(ll i=1; i<=N; i++){
        int flag = 0;
        if(frq[A[i]]>=2) continue;
        for(ll j=2; j<=sqrt(A[i]); j++){
            if(A[i]%j==0){
                if(frq[j]) flag = 1;
                if(frq[A[i]/j]) flag = 1;
            }
        }
        if(flag==0) ans++;
    }
    cout<<ans;
}

int main(){
    rapido;
    ll T=1; //cin>>T;
    while(T--){
        code_idhr_h();
    }
    return 0;
}

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

int main() {
  vector<int> vec(5);
  for(int i=0;i<5;i++){
    cin >>vec.at(i);
  }
  int ans=0;
  for(int i=0;i<5;i++){
    ans+=10*((vec.at(i)-1)/10 +1);
  }
  int minv=10;
  for(int i=0;i<5;i++){
    if(vec.at(i)%10==0){
      continue;
    }
    minv=min(minv,vec.at(i)%10);
  }
  cout <<ans-10+minv<<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<utility>
#include<queue>
#include<stdbool.h>
#include<math.h>
#include<sstream>
typedef long long ll;
#define N (1000000000+7)
#define INF (1e18)
using namespace std;
typedef pair<int, int> P;

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

int d[55][55];

char board[55][55];
int h, w;

int bfs() {
	queue<P>q;
	for (int i = 1;i <= h;i++) {
		for (int j = 1;j <= w;j++) {
			d[i][j] = INF;
		}
	}
	q.push(P(1, 1));
	d[1][1] = 0;
	while (!q.empty()) {
		P p = q.front();q.pop();
		if ((p.first == h) && (p.second == w))break;
		for (int i = 0;i < 4;i++) {
			int nx = p.first + dx[i];
			int ny = p.second + dy[i];
			if ((1 <= nx) && (nx <= h) && (1 <= ny) && (ny <= w) && (board[nx][ny] != '#') && (d[nx][ny] == INF)) {
				q.push(P(nx, ny));
				d[nx][ny] = d[p.first][p.second] + 1;
			}
		}
	}
	return d[h][w];
}

ll l[1010];
ll n, A, B, C;
ll dfs(ll u, ll a, ll b, ll c) {
	if (u == n) {
		if (min(a, min(b, c)) > 0) {
			return (ll)abs(a - A) + (ll)abs(b - B) + (ll)abs(c - C) - 30;
		}
		else return INF;
	}
	ll r1 = dfs(u + 1, a, b, c);
	ll r2 = dfs(u + 1, a + l[u], b, c) + 10;
	ll r3 = dfs(u + 1, a, b + l[u], c) + 10;
	ll r4 = dfs(u + 1, a, b, c + l[u]) + 10;
	return min(r1, min(r2, min(r3, r4)));
}

int main(void) {
	cin >> n >> A >> B >> C;
	for (ll i = 0;i < n;i++)cin >> l[i];
	cout << dfs(0, 0, 0, 0) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
#include <string>
//#include <algorithm>
//#include <utility>
//#include <stack>
//#include <queue>
//#include <tuple>
//#include <set>
//#include <map>
//#include <unordered_map>
//#include <vector>
//#include <functional>
//#include <bitset>
//#include <cmath>
using namespace std;

typedef long long lint;
typedef unsigned long long ulint;
#define MOD 1000000007

lint mabs(lint a){
    return a<0?(-a):a;
}
int main(){
    int A[100002],B[100002],C[100002];
    A[0]=0;
    int N;
    lint sum=0;
    cin >> N;
    for(int i=1;i<=N;i++){
        cin >> A[i];
        B[i]=mabs(A[i-1]-A[i]);
        sum+=B[i];
        if(i>=2) C[i-1]=B[i-1]+B[i]-mabs(A[i-2]-A[i]);
    }
    A[N+1]=0;
    B[N+1]=mabs(A[N]-A[0]);
    sum+=B[N+1];
    C[N]=B[N]+B[N+1]-mabs(A[N-1]-A[N+1]);

    for(int i=1;i<=N;i++){
        cout << (sum-C[i]) << endl;
    }
    return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    ll X, Y;
    cin >> X >> Y;
    if (abs(X - Y) <= 1) cout << "Brown" << '\n';
    else cout << "Alice" << '\n';
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Map<String, Integer> blues = new HashMap<String, Integer>();
        for(int i = 0; i < N; i++){
            String s = sc.next();
            if(blues.containsKey(s)){
                int a = blues.get(s);
                blues.replace(s, a+1);
            }else{
                blues.put(s, 1);
            }
        }
        int M = sc.nextInt();
        Map<String, Integer> reds = new HashMap<String, Integer>();
        for(int i = 0; i < M; i++){
            String t = sc.next();
            if(reds.containsKey(t)){
                int b = reds.get(t);
                reds.replace(t, b+1);
            }else{
                reds.put(t, 1);
            }
        }
        int ans = 0;
        for(String s: blues.keySet()){
            ans = Math.max(ans, blues.get(s) - reds.getOrDefault(s, 0));
        }
        System.out.println(ans);
        sc.close();
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;--k;
    cout << a[k] << endl;   
    return 0;
}

Measured memory_bytes: 256
def is_kaibun(kaibun):
    for i in range(len(kaibun)//2):
        if kaibun[i] != kaibun[-i-1]:
            return True
    return False



S=input()
if is_kaibun(S):
    print('No')
    exit()
N=len(S)
N2=(N-1)/2
S2 = S[:int(N2)]
if is_kaibun(S2):
    print('No')
    exit()
N3=(N+3)/2
S3 = S[int(N3)-1:]
if is_kaibun(S3):
    print('No')
    exit()
print('Yes')

Measured memory_bytes: 3064
def partition(A,p,r):
    x = A[r]
    i = p
    for j in range(p,r):
        if A[j] <= x:
            A[j],A[i] = A[i],A[j]
            i += 1
    A[r],A[i] = A[i],A[r]
    return i

n = int(input())
A = list(map(int,input().split()))
i = partition(A,0,n-1)
A[i] = "[{}]".format(A[i])
print(*A)

Measured memory_bytes: 18196
n, m = map(int, input().split())
List = list(map(int, input().split()))
List.sort(reverse = True)

sums = 0
for i in range(n):
  sums += List[i]
border = sums / (4*m)

counter = 0
for i in range(n):
  if List[i] >= border:
    counter += 1
  else:
    break
if counter >= m:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include <iostream>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)

int dp[1010][1010], map[1010][1010];

struct P{
    int x, y;
};

int H, W, N;

P walk(int x, int y){
    if(x > W || y > H){
        return {x, y};
    }

    if(map[y][x] == 1){// east
        return walk(x+1, y);
    }
    return walk(x, y+1);
}

int main(){
    while(std::cin >> H >> W >> N, H){
        FOR(i, 1, H+1){
            FOR(j, 1, W+1){
                std::cin >> map[i][j];
            }
        }

        FOR(i, 0, 1010){
            FOR(j, 0, 1010){
                dp[i][j] = 0;
            }
        }

        dp[1][1] = N-1;

        FOR(i, 1, H+1){
            FOR(j, 1, W+1){
                if(dp[i][j] % 2 == 0){
                    dp[i+1][j] += dp[i][j] / 2;
                    dp[i][j+1] += dp[i][j] / 2;
                }else{
                    if(map[i][j] == 1){// EAST
                        dp[i][j+1] += (dp[i][j] + 1) / 2;
                        dp[i+1][j] += (dp[i][j] - 1) / 2;
                    }else{// NORTH
                        dp[i+1][j] += (dp[i][j] + 1) / 2;
                        dp[i][j+1] += (dp[i][j] - 1) / 2;
                    }
                }
            }
        }

        // FOR(i, 1, 11){
        //     FOR(j, 1, 11){
        //         std::cout << dp[i][j] << " ";
        //     }
        //     std::cout << std::endl;
        // }

        FOR(i, 1, H+1){
            FOR(j, 1, W+1){
                if(dp[i][j] % 2 == 1){
                    map[i][j] = !map[i][j];
                }
            }
        }

        auto p = walk(1, 1);
        std::cout << p.y << " " << p.x << std::endl;
    }
}

Measured memory_bytes: 9156
import heapq
x,y,a,b,c=map(int,input().split())
p=sorted(list(map(int,input().split())),reverse=True)
q=sorted(list(map(int,input().split())),reverse=True)
r=list(map(lambda x:-int(x),input().split()))
heapq.heapify(r)
for i in range(x):
    heapq.heappush(r,-p[i])
for i in range(y):
    heapq.heappush(r,-q[i])
ans=0
for i in range(x+y):
    ans-=heapq.heappop(r)
print(ans)

Measured memory_bytes: 30176
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int map[101][101];
int main(void) {
	int x, y;
	int sumx, sumy;
	cin >> x >> y;
	for (int i = 0; i < x; i++) {
		sumx = 0;
		for (int j = 0; j < y; j++) {
			cin >> map[i][j];
			sumx += map[i][j];
		}
		map[i][y] = sumx;
	}
	for (int i = 0; i <= y; i++) {
		sumy = 0;
		for (int j = 0; j < x; j++) {
			sumy += map[j][i];
		}
		map[x][i] = sumy;
	}
	for (int i = 0; i <= x; i++) {
		for (int j = 0; j <= y; j++) {
			if (j)cout << " ";
			cout << map[i][j];
		}
		cout << endl;
	}
}


Measured memory_bytes: 3116
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
#include<iterator>
#include<queue>
#include<stack>
#include<cctype>
#include<deque>
#include<time.h>
#include<bitset>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<sstream>
#include<random>
#include<numeric>
//by Skeef79

typedef long long ll;
typedef long double ld;

typedef unsigned long long ull;

#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#define pb push_back
#define en '\n'
#define for0(i,n) for(int i = 0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>
#define SZ(a) int(a.size())
#define what_is(x) cout<<#x<<" is "<<x<<en;


using namespace std;

const int INF = 2000000000;
const ll LINF = 2000000000000000000;

template<typename T> void print(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

template <typename T> void input(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
		for (int j = 0; j < a[i].size(); j++)
			cin >> a[i][j];

}

void solve()
{
	ll a;
	cin >> a;
	cout << a + a * a + a * a*a;
}

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

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif

	//freopen("luigi.in", "r", stdin);
	//freopen("luigi.out", "w", stdout);

	int tst = 1;
	//cin >> tst;

	while (tst--)
		solve();
}


Measured memory_bytes: 3612
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
	input! {
		cs: Chars,
	}

	for i in (0..cs.len()).step_by(2) {
		print!("{}", cs[i]);
	}
	println!("");
}



Measured memory_bytes: 2404
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

const double root12 = sqrt(12);

struct pos
{
    double x, y;
};

void posprint (pos p) { cout << setprecision(8) << p.x << " " << p.y << endl; }

void koch(pos p1, pos p2, int n)
{
    double dx = p2.x - p1.x;
    double dy = p2.y - p1.y;
    pos s = {p1.x + dx / 3., p1.y + dy / 3.};
    pos t = {p2.x - dx / 3., p2.y - dy / 3.};
    pos u = {(p1.x + p2.x) / 2. - dy / root12, (p1.y + p2.y) / 2. + dx / root12};
    if (n)
    {
        n--;
        koch(p1, s, n);
        koch(s, u, n);
        koch(u, t, n);
        koch(t, p2, n);
    }
    else posprint(p1);
}

int main(void)
{
    int N;
    cin >> N;
    pos p1 = {0., 0.};
    pos p2 = {100., 0.};
    cout << fixed;
    koch(p1, p2, N);
    posprint(p2);
    return 0;
}


Measured memory_bytes: 3272
import java.util.Scanner;
public class Main {
	static int N;
	static int K;
	static long[] max;
	static long[] min;
	public static long calc(int i) {
		if(i==K) {
			for(int j=0;j<i;j++) {
				max[i-K]+=N-j;
				min[i-K]+=j;
			}
			return max[i-K]-min[i-K]+1;
			}
		else{
			max[i-K]=max[i-K-1]+(N+1-i);
			min[i-K]=min[i-K-1]+i-1;
		return max[i-K]-min[i-K]+1;
		}
	}
	public static void main(String args[]) {
		Scanner sc=new Scanner(System.in);
		N=sc.nextInt();
		K=sc.nextInt();
		max=new long[N+2-K];
		min=new long[N+2-K];
		max[0]=0;
		min[0]=0;
		long ans=0;
		for(int i=K;i<=N+1;i++) {
			ans+=calc(i);
			ans%=1000000007;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 38720
import sys
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

n = read_int()[0]
B = read_int()

def solve():
    for i in range(n):
        if B[i] > i + 1:
            print(-1)
            return

    res = []
    for i in range(n):
        app = 0
        index = 0
        for j in range(len(B)):
            if B[j] == j + 1:
                app = max(app, B[j])
                index = j
        B.pop(index)
        res.append(app)

    for i in range(n):
        print(res[n - 1 - i])
    return


if __name__ == "__main__":
    solve()

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

int main(){
  int N;
  cin>>N;
  int a[N+2];
  a[0]=0;
  a[N+1]=0;
  for (int i=0;i<N;i++){
    cin>>a[i+1];
  }
  int b[N+1];
  int total=0;
  for(int i=0;i<N+1;i++){
    b[i]=abs(a[i+1]-a[i]);
    total=total+b[i];
  }
  for (int i=0;i<N;i++){
    cout<<total+abs(a[i]-a[i+2])-abs(a[i+1]-a[i])-abs(a[i+2]-a[i+1])<<endl;
  }
  return 0;
}

        

Measured memory_bytes: 2048
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

lli body(lli a, lli b){
	return (a-b)*(a-b);
}
int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	lli n, m;
	cin >> n >> m;
	vector<lli> wa(n, 0);
	vector<lli> ac(n, 0);

	rep(i,m){
		lli P;
		string ss;
		cin >> P >> ss;
		if(ss == "AC"){
			ac[P-1]++;
		}else{
			if(ac[P-1] == 0) wa[P-1]++;
		}
	}
	lli w=0;
	lli a=0;
	rep(i,n){
		if(ac[i] >= 1){
			a++;
			w += wa[i];
		}
	}
	cout << a << " " << w << endl;
 	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f|=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=200005;
int n,a[N];
int x[N],y[N];
int check(int v){
	LL pw[233];
	int tot=0,s=0,tmp=n;
	while (tmp)
		s++,tmp/=v;
	pw[0]=1;
	for (int i=1;i<=s;i++)
		pw[i]=pw[i-1]*v;
	a[0]=y[0]=x[0]=0;
	for (int i=1;i<=n;i++){
		if (a[i]>a[i-1]){
			tot++;
			x[tot]=a[i];
			y[tot]=0;
		}
		else {
			while (tot>0&&x[tot-1]>=a[i])
				tot--;
			int len=x[tot]-a[i];
			while (len&&y[tot])
				y[tot]/=v,len--;
			x[tot]=a[i];
			y[tot]++;
			for (int j=tot;j>=1;j--){
				if (x[j]-x[j-1]<=s&&y[j]>=pw[x[j]-x[j-1]]){
					y[j-1]++;
					y[j]-=pw[x[j]-x[j-1]];
				}
				else
					break;
			}
		}
	}
	return y[0]==0;
}
int ck1(){
	for (int i=1;i<n;i++)
		if (a[i]>=a[i+1])
			return 0;
	return 1;
}
int main(){
	n=read();
	for (int i=1;i<=n;i++)
		a[i]=read();
	if (ck1())
		return puts("1"),0;
	int L=2,R=n,ans=n;
	while (L<=R){
		int mid=(L+R)>>1;
		if (check(mid))
			R=mid-1,ans=mid;
		else
			L=mid+1;
	}
	cout << ans;
	return 0;
}
/*
10
2 4 4 4 5 4 3 2 2 2
*/

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

using namespace std;

//#define dump(i) cout << "[*] " #i " : " << i << endl
#define dump(i)

int main() {
        int n;
        cin >> n;
        vector<int> x(n+1);
        vector<int> y(n+1);
        vector<int> t(n+1);
        t[0] = x[0] = y[0] = 0;
        for (int i = 1; i <= n; ++i) {
                cin >> t[i] >> x[i] >> y[i];
        }

        bool flag = true;
        for (int i = 0; i < n; ++i) {
                const int dx = abs(x[i+1] - x[i]);
                const int dy = abs(y[i+1] - y[i]);
                const int dt = t[i+1] - t[i];
                dump(dx);
                dump(dy);
                dump(dt);
                flag &= (dt >= dx + dy);
                flag &= ((dt - dx - dy) % 2 != 1);
                dump(flag);
                if (!flag) {
                        break;
                }
        }

        cout << (flag ? "Yes" : "No") << endl;
        return 0;
}

Measured memory_bytes: 1408
#include <string>
#include <string.h>
#include <iostream>
#include <queue>
#include <math.h>
#include <stdio.h>
using namespace std;
const int mod = 100000000;
int a[3][222];
int sum[3][222];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=2;i++)
	{
		for(int j=1;j<=n;j++)
			scanf("%d",&a[i][j]);
	}
	for(int i=1;i<=2;i++){
		for(int j=1;j<=n;j++){
			sum[i][j]=sum[i][j-1]+a[i][j];
		}
	}
	int ans = 0;
	for(int i=1;i<=n;i++){
		ans=max(sum[1][i]+sum[2][n]-sum[2][i-1],ans);
	}
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 256