akhauriyash/Code-Regression huggingface dataset:
/* Author : Harshit Jain a.k.a. iharshit009 */
#include <bits/stdc++.h>
#define vi               vector<int>
#define pb(x)            push_back(x)
#define all(x)           x.begin(), x.end()
#define sortall(x)       sort(all(x))
#define sortrev(x)       sort(all(x), greater<int>())
#define debug(x)         cout << '>' << #x << ':' << x << endl;
#define int              long long
#define ld               long double
#define endl 			 "\n";
#define mp 				 make_pair
#define pii 			 <int, int>
#define lb 				 lower_bound
#define ub				 upper_bound
#define len(a)           int((a).size())
#define prec(n)          fixed<<setprecision(n)
#define cnt(n)           __builtin_popcountll(n)
#define pi               pair<int, int>
const int mod = 1000000007;
using namespace std;
using namespace std::chrono;
const int N = 1e5 + 5; 
int n;
int a[N][4];
int dp[N][4];


int func(int day, int flag){
	if(day == n)return 0;
	if(dp[day][flag] != -1) return dp[day][flag];
	int maxi = 0;
	if(flag == 0){
		maxi = max(maxi, a[day][1] + func(day + 1, 1));
		maxi = max(maxi, a[day][2] + func(day + 1, 2));
		maxi = max(maxi, a[day][3] + func(day + 1, 3));
	}
	else if(flag == 1){
		maxi = max(maxi, a[day][2] + func(day+1, 2));
		maxi = max(maxi, a[day][3] + func(day+1, 3));
	}
	else if(flag == 2){
		maxi = max(maxi, a[day][1] + func(day+1, 1));
		maxi = max(maxi, a[day][3] + func(day+1, 3));

	}
	else{
		maxi = max(maxi, a[day][1] + func(day+1, 1));
		maxi = max(maxi, a[day][2] + func(day+1, 2));
	}
	return dp[day][flag] =  maxi;
}



int32_t main(){
auto start = high_resolution_clock::now(); // starting clock
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int t;
t = 1;
// cin >>t;q
while(t--){

// int n;
cin >>n;
memset(dp,-1,sizeof(dp));
for(int i = 0; i<n; i++){
	for(int j = 1; j<4; j++){
		cin >> a[i][j];
	}
}
cout << func(0,0);





// when app updates how does the data remains in the app, and not changes in the activities, but add additional features and why does app restarts after it gets updated



}
auto stop = high_resolution_clock::now(); // stop clock
auto duration = duration_cast<microseconds>(stop - start);  // printing duration
cerr << "Time taken by function: " << duration.count() << " milliseconds" << endl; 
return 0;
}

Measured memory_bytes: 17616
#include <bits/stdc++.h>
using namespace std;
#define TAM 500
#define MAXC 30
int C[TAM][TAM];
int cost[MAXC][MAXC];
int color[3], change[3][MAXC];

int main() {
  int n, nC;
  scanf ( "%d%d", &n, &nC );
  for ( int i = 0; i < nC; ++i )
    for ( int j = 0; j < nC; ++j )
      scanf ( "%d", &cost[i][j] );
  for ( int i = 0; i < n; ++i )
    for ( int j = 0; j < n; ++j )
      scanf ( "%d", &C[i][j] ), C[i][j]--;
  
  for ( int c = 0; c < nC; ++c )
    for ( int i = 0; i < n; ++i )
      for ( int j = 0; j < n; ++j )
        change[(i+j)%3][c] += cost[C[i][j]][c];

  int ans = INT_MAX;
  for ( int c0 = 0; c0 < nC; ++c0 )
    for ( int c1 = 0; c1 < nC; ++c1 )
      for ( int c2 = 0; c2 < nC; ++c2 )
        if ( __builtin_popcount((1<<c0)|(1<<c1)|(1<<c2)) == 3 ) {
          ans = min ( ans, change[0][c0] + change[1][c1] + change[2][c2] );
        }
  printf ( "%d\n", ans );
  return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#define rep(i,n) for(int i=0;i<(n);++i)

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100000000;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
vector<vector<int>> d(1000,vector<int>(1000,INF));
vector<vector<char>> maze;
vector<pair<int,int>> goals;
P start;
int R,C,N;
int bfs(int sx,int sy,int gx,int gy){
  queue<P> que;
  que.push(P(sx,sy));
  d[sx][sy]=0;
  while(que.size()){
    P p=que.front();que.pop();
    if(p.first==gx&&p.second==gy)break;
    rep(i,4){
      int nx = p.first+dx[i];
      int ny = p.second+dy[i];
      if(0<=nx && nx<R && 0<=ny && ny<C && maze[nx][ny] != 'X' && d[nx][ny]==INF){
        que.push(P(nx,ny));
        d[nx][ny] = d[p.first][p.second]+1;
      }
    }
  }
  return d[gx][gy];
}
      
int main(){
  cin >> R >> C >>N;
  maze.resize(R);
  goals.resize(N);
  rep(i,R){
    rep(j,C){
      char c;
      cin >> c;
      maze[i].push_back(c);
    }
  }
  /*rep(i,R){
    rep(j,C){
      cout << maze[i][j];
    }
    cout << endl;
  }*/
  goals[0].first = 10000;
  rep(i,N){
    rep(j,R){
      rep(k,C){
        int a = i+1;
        char ka = a+'0';
        if(maze[j][k]=='S'){
          start.first=j;
          start.second=k;
        }
        if(maze[j][k]==ka){
          goals[i].first=j;
          goals[i].second=k;
        }
      }
    }
  }
  //cout << start.first << "," << start.second << endl;
  /*rep(i,N){
    cout << goals[i].first << "," << goals[i].second << endl;
  }*/
  int path = bfs(start.first,start.second,goals[0].first,goals[0].second);
  rep(i,N-1){
    rep(j,1000){
      rep(k,1000){
        d[j][k] = INF;
      }
    }
    path+=bfs(goals[i].first,goals[i].second,goals[i+1].first,goals[i+1].second);
  }
  cout << path << endl;
                                                                   
  
  //int res = bfs();
  //cout << res << endl;


  return 0;
}


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

using namespace std;

#define bug(x) cerr << #x << " = " << x << '\n'
#define ll     long long
#define x      first
#define y      second
#define eb     emplace_back
#define maxn
#define mod    1000000007

int main() {
        #ifndef ONLINE_JUDGE
            //freopen(".inp","r",stdin);
        #endif // ONLINE_JUDGE

//        ios_base::sync_with_stdio(0);
//        cin.tie(0); cout.tie(0);

        int n, x, t;
        cin >> n >> x >> t;
        cout << (ll) t * ((n / x) + (bool) (n % x));
}





Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define M 1000000007
#define INF ((1LL<<62LL) - 1)

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,k; cin >> n >> k;
    int p[n+1], c[n+1];

    for(int i=1;i<=n;i++) cin >> p[i];
    for(int i=1;i<=n;i++) cin >> c[i];

    int ans  = -INF;

    for(int i=1;i<=n;i++){
        int start = p[i];
        vector<int> v;

        while(true){
            v.push_back(c[start]);
            start = p[start];
            if(start == p[i]) break;
        }

        int times = k/v.size();
        int extra = k%v.size();

        int sum = 0;

        for(int j=0;j<v.size();j++){
            sum += v[j];
        }

        int temp = 0;
        if(times == 0){
            for(int j=0;j<extra;j++){
                temp += v[j];
                ans = max(ans, temp);
            }
            continue;
        }

        temp = (times - 1LL)*sum;
        if(sum < 0) temp = 0;
        if(times >= 2){
            ans = max(ans, temp);
        }

        for(int j=0;j<v.size();j++){
            temp += v[j];
            ans = max(ans, temp);
        }

        for(int j=0;j<extra;j++){
            temp += v[j];
            ans = max(ans, temp);
        }

    }

    cout << ans << "\n";




}


Measured memory_bytes: 3836
import scala.math._

object Main extends App {

  val YES = "YES"
  val Yes = "Yes"
  val NO = "NO"
  val No = "No"

  val input: Array[Array[Int]] = Array.ofDim(6, 6000000)
  ///////////////////////////////////////////

  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt
//  val b = sc.nextInt
  val a = List.fill(n)(sc.nextInt)
//  val b = List.fill(n)(sc.nextInt)
//  val c = List.fill(n - 1)(sc.nextInt)

  val ans = 1 / a.foldLeft(0.0) { case (acc, in) =>
    acc + 1.0 / in
  }
  println(ans)

  ///////////////////////////////////////////

  def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =
    Iterator.iterate(start)(_ + step).takeWhile(_ <= end)

  def lcm(a :Int, b :Int): Int =
    a / gcd(a, b) * b

  def lcm(a :Long, b :Long): Long =
    a / gcd(a, b) * b

  def gcd(a: Int, b: Int): Int =
    if (b == 0) a else gcd(b, a % b)

  def gcd(a: Long, b: Long): Long =
    if (b == 0) a else gcd(b, a % b)

  def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =
    a.get(key) match {
      case Some(v) => a.updated(key, f(value, v))
      case _ => a + (key -> value)
    }
}

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

#define forn(i, n) for(int i = 0; i < n; i++)
#define for1(i, n) for(int i = 1; i <= n; i++)
#define PrintArray(a,n) for(int i=0;i<n;i++) cout << a[i] << " "; cout << endl;
#define CopyArray(a,temp,n) for(int i=0;i<n;i++) temp[i]=a[i];
#define InputArray(a,n) for(int i=0;i<n;i++) cin >> a[i];
#define MAX(a,b,c) max(max(a,b),c)
#define SumInRange(a,b) ((b*(b+1))/2)-(((a-1)*(a))/2)
#define Different_Random srand(time(NULL))
#define Random(a,b) (rand()%((b+1)-a))+a
#define __delete(v,n) v.erase(remove(v.begin(),v.end(),n),v.end())

#define Cases  cout << "Case " << ++Case << ": ";
#define __test int tt; int Case=0; cin >> tt; while(tt--)
#define newline cout << "\n";

#define read(x)    freopen(#x, "r", stdin)
#define write(x)   freopen(#x, "w", stdout)

#define all(x)     x.begin(), x.end()
#define dbg(args...)    {string sss(#args);sss+=',';cerr<<"-->";debugger::call(all(sss), args);cerr<<"\n";}
#define dbgA(A, n)      {cerr<<"-->"<<#A<<"=(";forn(i, n)cerr<<A[i]<<" ";cerr<<")\n";}
#define dbgA2(A, n, m)  {cerr<<"-->"<<#A<<"=\n";forn(i, n){forn(j, m){cerr<<setw(4)<<A[i][j]<<" ";}cerr<<"\n";}cerr<<"\n";}

struct debugger{
    typedef string::iterator si;
    static void call(si it, si ed) {}
    template<typename T, typename ... aT>
    static void call(si it, si ed, T a, aT... rest) {
        string b;
        for(; *it!=','; ++it) if(*it!=' ')b+=*it;
        cerr << b << " = " << a << " ";
        call(++it, ed, rest...);
    }
};

template<typename T>
T Max(T a) {return a;}

template<typename T, typename... Args>
T Max(T a, Args... args){ return a > Max(args...)? a : Max(args...);}

template<typename T>
T Min(T a) {return a;}

template<typename T, typename... Args>
T Min(T a, Args... args){ return a < Min(args...)? a : Min(args...);}


//int dx[] = {1, -1, 0, 0, -1, 1, -1, 1};
//int dy[] = {0, 0, 1, -1, -1, -1, 1, 1};
//int knight_x[] = {2, 2, -2, -2, 1, 1, -1, -1};
//int knight_y[] = {1, -1, 1, -1, 2, -2, 2, -2};

/*
cout.precision(x);
cout << fixed;
*/

typedef long long int ll;
typedef unsigned long long int ull;
const double GOLD = (1.0 + sqrt(5.0))/2.0;
const double EPS = 1e-9;
const int INF = 0x7f7f7f7f;
const double PI = 3.141592653589793;
const double E = 2.718281828459045;

ll expo(ll a, ll n)
{
    ll result = 1;
    while(n)
    {
        if(n%2) result*=a;
        a*=a; n/=2;
    }
    return result;
}

ll mod_expo(ll x,ll y,ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1) res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
const int MOD = 1e9+7;
int main()
{
    #ifdef TarekHasan
        read(input.txt);
    #endif // TarekHasan
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);

    string str; cin >> str;
    if(str[str.size()-1]=='s')
        cout << str << "es\n";
    else
        cout << str << "s\n";

    cerr << "time = " << clock() << " ms" << '\n';
    return 0;
}



Measured memory_bytes: 3684
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
using ll = long long;
ll gcd(ll x,ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}
bool solve(){
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a<b) return 0;
	a -= b;
	if(d<b) return 0;
	ll e = d-b;
	ll g = gcd(b,e);
	ll mx = b-g+a%g;
	if(mx>c) return 0;
	return 1;
}
int main(){
	int T;
	cin>>T;
	rep(i,T){
		cout<<(solve()?"Yes":"No")<<endl;
	}
}


Measured memory_bytes: 256
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static final long MOD = 1000000007;
	public static void main(String[] args) {
		int i=0,j=0,k=0;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		long a = parseLong(sc.next());
		long b = parseLong(sc.next());
		long[] x = new long[n];
		for (i = 0; i < n; i++) {
			x[i] = parseLong(sc.next());
		}
		sc.close();
		long[] xd = new long[n-1];
		for (i = 0; i < n-1; i++) {
			xd[i] = x[i+1] - x[i];
		}
		long cnt=0;
		for (i = 0; i < n-1; i++) {
			cnt+=Math.min(xd[i]*a, b);
		}
		out.println(cnt);
	}
}


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

const int INF = 100;

int main()
{
    int n;
    cin >> n;
    vector<int> c(26, INF);
    rep(i, n) {
        string s;
        cin >> s;
        vector<int> cnt(26, 0);
        rep(j, s.size()) {
            cnt[s[j] - 'a']++;
        }
        rep(j, 26) {
            c[j] = min(c[j], cnt[j]);
        }
    }
    string ans;
    rep(i, 26) {
        rep(j, c[i]) {
            ans.push_back('a' + i);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3604
#include "bits/stdc++.h"
using namespace std;
#define int long long
const int N = 1e5 + 5;

int32_t main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    if (n < 10) cout << n;
    else {
        int ans = 0;
        bool all9 = 1;
        while (n >= 10) {
            ans += 9;
            if (n % 10 != 9) all9 = 0;
            n /= 10;
        }
        if (all9) ans += n;
        else ans += (n - 1);
        cout << ans;
    }
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
import java.util.stream.IntStream;


public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        byte[] a = scan.next().getBytes();
        System.out.println((char)a[0]  + "" + (a.length - 2) + (char) a[a.length-1]);
    }

}

Measured memory_bytes: 21716
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

constexpr int M = 1000000007;

int main() {
  string s;
  cin >> s;
  int n = s.length();
  int m = 0;
  map<int, int> cnt;
  int dm = 1;
  reverse(begin(s), end(s));
  for (int i = 0; i < n; i++) {
    if (s[i] == '?') {
      cnt[dm]++;
    }
    else {
      int ds = s[i] - '0';
      m += dm * ds;
      m %= 13;
    }
    dm *= 10;
    dm %= 13;
  }
  vector<vector<int>> dp(2, vector<int>(13));
  dp[0][m] = 1;
  for (auto&& p : cnt) {
    int t = p.second;
    int k = p.first;
    for (int i = 0; i < t; i++) {
      fill(begin(dp[1]), end(dp[1]), 0);
      for (int q = 0; q < 13; q++) {
        for (int l = 0; l < 10; l++) {
          dp[1][(q + l * k) % 13] += dp[0][q];
          dp[1][(q + l * k) % 13] %= M;
        }
      }
      swap(dp[0], dp[1]);
    }
  }
  cout << dp[0][5] << endl;
}


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

int gcd(int big, int small);

int main() {
    int big, small;
    cin >> big >> small;

    if ( big < small ) {
        int tmp = big;
        big = small;
        small = tmp;
    }

    cout << gcd(big, small) << endl;
}

int gcd(int big, int small) {
    while ( small != 0 ) {
        int tmp = small;
        small = big % small;
        big = tmp;
    }

    return big;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
const int n_max=1e5+5;
vector<int> g[n_max];
int color[n_max];
bool ok=true;

void dfs(int v, int col){
  if(color[v]==-1){
    color[v]=col;
    for(auto i : g[v]){
      dfs(i, (col+1)%2);
    }
  }
  else if(color[v]!=col){
    ok=false;    
  }
}



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

  ll n,m;
  cin >> n >> m;
  int a,b;
  rep(i,m){
    cin >> a >> b;
    a--;b--;
    g[a].pb(b);
    g[b].pb(a);
  }
  rep(i,n) color[i]=-1;
  dfs(0,0);
  if(ok){
    ll ta,tb;
    ta=tb=0;
    rep(i,n){
      if(color[i]) ta++;
      else tb++;
    }
    cout <<ta*tb-m << endl;
  }
  else cout << n*(n-1)/2-m << endl;
  
  return 0;
    

}


Measured memory_bytes: 6528
N=gets.to_i
A=gets.split.map(&:to_i).zip(1..N).sort.reverse
@memo=Array.new(N){Array.new(N)}
def dfs(i,l)
  return 0 if i==N
  return @memo[i][l] if @memo[i][l]
  x=A[i][0]*A[i][1]
  y=A[i][0]*(1+l)
  z=A[i][0]*(N-(i-l))
  @memo[i][l] = [x-y+dfs(i+1,l+1), z-x+dfs(i+1,l)].max
end
p dfs(0,0)

Measured memory_bytes: 45876
#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() {
    map<int, int> mp;
    rep(i,3) {
        int n;
        cin >> n;
        mp[n]++;
    }
    string ans = "NO";
    if (mp[5] == 2 && mp[7] == 1) ans = "YES";
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1)
int sqr(int x){
  return x*x;
}
double miin(double a,double b){
  if(a>b) return a;
  else return b;
}
int main(){
   int a, b, h,m;
   cin>>a>>b>>h>>m;
   /*float goc,c;
   goc=min(abs(2*pi*(h+m/60.0)/12.0-2*pi*m/60.0),2*pi-abs(2*pi*(h+m/60.0)/12.0-2*pi*m/60.0));
   c=sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(goc));
   cout<<fixed<<setprecision(15)<<c;*/
   double goc_h,goc_p,res;
   goc_h=(1.0)*(2*pi*(h+m/60.0))/12;
   goc_p=(1.0)*(2*pi*m)/60;
   res=abs(goc_h-goc_p);
   res=miin(res,2*pi-res);
   res=sqrt(sqr(a)+sqr(b)-2*a*b*cos(res));
   cout<<fixed<<setprecision(30)<<res;
    return 0;
}


Measured memory_bytes: 4228
#include<stdio.h>
int main(void)
{
	long long int a, b;
	char str;
	scanf("%lld %c %lld", &a,&str,&b);
	if (str == '+') printf("%lld\n", a + b);
	else if (str == '-') printf("%lld\n", a - b);
	return 0;
}

Measured memory_bytes: 128
//#include <bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<cstring>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<iterator>
#include<algorithm>
#include<bitset>

#define Filein(N) freopen("N", "r", stdin);
#define Fileout(N) freopen("N", "w", stdout);
#define sci(x) scanf("%d", &x)
#define sci2(x,y) scanf("%d%d", &x,&y)
#define scll2(x,y) scanf("%lld%lld",&x,&y)
#define scll(x) scanf("%lld",&x)
#define scd(x) scanf("%lf", &x)
#define scstr(x) scanf("%s", x)
#define pfi(x) printf("%d", x)
#define pfll(x) printf("%lld", x)
#define pfd(x) printf("%f", x)
#define pfstr(x) printf("%s", x)
#define ps printf(" ")
#define pn printf("\n")
#define pfdt printf("..")

#define For(var,start,end) for(int var=start; var<=end;i++)
#define rFor(var,start,end) for(int var=start; var>=end; i--)
#define TestCase int testcase, cs=1; cin>>testcase;while(testcase--)

#define mkp make_pair
#define pb push_back
#define fi first
#define se second

#define px(x) cout<<"X -> "<<x<<endl;
#define py(x) cout<<"Y = "<<x<<endl;
#define pz(x) cout<<"Z >> "<<x<<endl;
#define pstr(x) printf("%s\n",x);

using namespace std;
using ll = long long;
using vi = vector <int>;
using mpii = map<int,int>;
using si = set<int>;
using sll = set<ll>;
using vll= vector<ll>;

#define INF 1000000000
#define LINF 4000000000000000000
#define pi  (2*acos(0))
#define Mod 1000000007

 int main(){

 int n;
    sci(n);

    ll d = n+n*n+n*n*n;

    pfll(d);pn;



    return 0;
}







Measured memory_bytes: 3824
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def gcd(a,b):
    while b>0:
        a,b = b,a
        b %= a
    return a

def main():
    N,K = LI()
    a = LI()
    if max(a) < K:
        return 'IMPOSSIBLE'
    if K in a:
        return 'POSSIBLE'
    t = a[0]
    for c in a[1:]:
        t = gcd(c, t)
        if t <= 1:
            return 'POSSIBLE'
    for c in a:
        if (c > K) and (((c-K) % t) == 0):
            return 'POSSIBLE'

    return 'IMPOSSIBLE'


print(main())





Measured memory_bytes: 16644
#include <iostream>
#include <vector>
#include <sstream>
using namespace std;

int main()
{
  int K, X;
  cin >> K >> X;
  vector<int> ans;
  ans.push_back(X);
  for (int i = 1; i < K; i++)
  {
    ans.push_back(X + i);
    ans.insert(ans.begin(), X - i);
  }
  int index = 0;
  for (; index < ans.size() - 1; index++)
    cout << ans[index] << " ";
  cout << ans[index];

  return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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; }

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

void add(ll& a, ll b){
  a = (a+b) % MOD;
}

void mul(ll& a, ll b){
  a = (a*b) % MOD;
}

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

const ll maxf = 10000000;
ll fact[maxf+5];

void fact_init(){
  fact[0] = 1;
  for(ll i=1; i<=maxf; i++){
    fact[i] = (fact[i-1] * i) % MOD;
  }
}

ll comb(ll a, ll b){
  if(a<b || a<0 || b<0) return 0;
  if(fact[0] == 0) fact_init();
  return (fact[a] * modpow((fact[a-b]*fact[b])%MOD, MOD-2)) % MOD;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,k; cin>>n>>k;
  vll a(n);
  rep(i,n) cin>>a[i];
  vsort(a);
  ll max=0;
  irep(i,k-1,n){
    ll x=a[i]*comb(i,k-1);
    add(max,x);
  }
  ll min=0;
  reverse(all(a));
  irep(i,k-1,n){
    ll x=a[i]*comb(i,k-1);
    add(min,x);
  }
  ll ans=max-min;
  while(ans<0){
    ans+=MOD;
  }
  ans%=MOD;
  cout<<ans<<endl;
}

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

using namespace std;

const int maxn = 2e5+100;

int vet[maxn];

main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    int n;

    cin >> n;

    int maior1=0, maior2=0, id1, id2;

    for(int i=1; i<=n; i++){
        cin >> vet[i];
        if(vet[i]>maior1){
            maior1=vet[i];
            id1=i;
        }
    }

    for(int i=1; i<=n; i++){
        if(vet[i]>maior2 and id1!=i){
            maior2=vet[i];
            id2=i;
        }
    }

    for(int i=1; i<=n; i++){
        if(i==id1){
            cout << maior2 << endl;
        }
        else cout << maior1 << endl;
    }

    cout << endl;

    return 0;
}


Measured memory_bytes: 2432
////=====Bismillahir Rahmanir Rahim=====////

/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define ff first
#define ss second
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define edl "\n"
#define infinity 10000000000000000
#define mod 1000000007
#define cn continue
using namespace std;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<pii> vpi;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a <<","<< spc;
    err(++it, args...);
    cout<<edl;
}
///Bit manipulation

bool checkbit(ll mask,ll bit){return mask & (1LL<<bit);}
int setbit(int mask,int bit){ return mask | (1<<bit) ; }
int clearbit(int mask,int bit){return mask & ~(1<<bit);}
int togglebit(int mask,int bit){return mask ^ (1<<bit);}
int bitno(int mask) {return (int)__builtin_popcount(mask);}

int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

/// KNIGHT MOVE

int x_move[] = {2, 1, -1, -2, -2, -1, 1, 2};
int y_move[] = {1, 2, 2, 1, -1, -2, -2, -1};

///=====================================///

const long long maX=1e7+5;
//vector<ll>Graph[maX],cost[maX];
map<string,ll>check;
///check n=1;
///check corner case;

ll  prime[maX];
void isprime(ll n)
{
    for(ll i=1;i<=n;i++){
        for(ll j=i;j<=n;j+=i){
            prime[j]++;
        }
    }
    for(ll i=1;i<=maX;i++){
        prime[i]*=i;
    }
}
int main()
{
    ll n;
    cin>>n;
    isprime(n);
    ll sum=0;
    for(ll i=1;i<=n;i++)sum+=prime[i];
    cout<<sum<<endl;
}


Measured memory_bytes: 81744
#include<bits/stdc++.h>
#define HohleFeuerwerke using namespace std
#define MAXN 20005
HohleFeuerwerke;
int n;
string str;
map<string,int> m;
int most=0;
int main()
{
	ios::sync_with_stdio(false);
	cout.tie(0);cin.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++) cin>>str,m[str]++,most=max(most,m[str]);
	for(map<string,int>::iterator it=m.begin();it!=m.end();it++)
		if(it->second==most)
			cout<<(*it).first<<endl;
	return 0;
}

Measured memory_bytes: 23808
n = int(input())
a = list(map(int, input().split()))

count = {}
for ai in a:
  count[ai] = count.get(ai, 0) + 1

ans = 0
for key in count.keys():
  ans = max(ans, count.get(key - 1, 0) + count.get(key) + count.get(key + 1, 0))
print(ans)

Measured memory_bytes: 14180
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;

 
#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 oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
  
 

ll sum(ll n) {
ll m=0;
  while(n){
    m+=n%10;
    n/=10;
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}




 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
    ci(n);
  ll Sum=0;
  ll Min=INF;
  FOR(i,0,n){
    ll a;
      ci(a);
    if(a%10==0){
      Sum+=a;
    }
    else{
      chmin(Min,a);
      Sum+=a;
    }
  }

  if(Sum%10==0){
    Sum-=Min;
  }
  ll z=0;
  co(max(z,Sum))
}

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


int main(){
    int n;
    cin >> n  ;
    double a[n] ;
    for(int i=0;i<n;++i) cin >> a[i] ;

    double tmp = 0 ;
    for(int i=0;i<n;++i){
    tmp += 1.0/a[i] ;
    }
    tmp = 1.0/tmp ;
  
    cout << setprecision(9) << fixed << tmp << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    cin>>s;
    int flag=0;
    for (int i=0;i<s.size();i++) {
        if (s.at(i)=='A') {
            for (int j=s.size()-1;j>i;j--) {
                if (s.at(j)=='Z') {
                    cout<<j-i+1<<endl;
                    flag=1;
                    break;
                }
            }
        }
        if (flag==1) {
            break;
        }
    }
}

Measured memory_bytes: 640
import itertools, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    N =I()

    kuku = {i * j for i, j in itertools.product(range(1, 10), repeat=2)}
    if N in kuku:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    resolve()

Measured memory_bytes: 9212
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main(){
	int n;
	double t,a;
	double min = 1e09;
	int res;
	cin >> n;
	cin >> t >> a;
	vector<double> h(n);
	for(int i=0;i<n;++i)cin >> h[i];
	for(int i=0;i<n;++i){
		double tmp = abs((t - h[i] * 0.006) - a);
		if(tmp < min){
			res = i;
			min = tmp;
		}
	}
	cout << res + 1 << endl;
}

Measured memory_bytes: 256
n = int(input())
count = [0]*n
ans = 1
flag = True
for d in map(int,input().split()):
    if flag:
        if d!=0:
            print(0)
            exit()
        flag = False
    count[d] += 1
for i in range(1,n):
    if count[0]!=1:
        ans = 0
        break
    if count[i]==0:
        if any(k!=0 for k in count[i:]):
            ans = 0
        break
    ans *= (count[i-1]**count[i])%998244353
    
print(ans%998244353)

Measured memory_bytes: 17960
#include<iostream>
#include<string>

int main(){
    std::string ans,str,buf;
    str=' ';
    std::cin>>ans;
//読み込んだ文字列を1つの文字列に格納
    while(1){
        std::cin>>buf;
        if(buf=="END_OF_TEXT"){
            break;
        }else{
            str+=buf+' ';
        }
    }
//格納終わり

//格納した文字列の大文字を小文字に変える
    int i;
    for(i=0;i<str.size();i++){
        if('A'<=str[i]&&str[i]<='Z'){
            str[i]+=32;
        }else{
            str[i]=str[i];
        }
    }
//変換終わり->ここまではok
    
//ここから文字列と単語の比較をしていく
    int count=0;
    std::string op_h,op_b;
    std::string str_part;
    for(i=1;i<(str.size()-ans.size());i++){
        str_part=str.substr(i,ans.size());//単語の長さ分の要素を抜き出す
        if(str_part==ans){
            //抜き出した単語の前後がアルファベットかどうかを判定
            if('a'<=str[i-1]&&str[i-1]<='z'){
                op_h="No";
            }else{
                op_h="Yes";
            }
            if('a'<=str[i+ans.size()]&&str[i+ans.size()]<='z'){
                op_b="No";
            }else{
                op_b="Yes";
            }

            //前後がアルファベットでなければカウント
            if(op_h=="Yes"&&op_b=="Yes"){
                count++;
            }
        }
    }
    
    std::cout<<count<<std::endl;
    return 0;
}



Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	ll a,b;
	cin>>a>>b;
	cout<<(a-1)*(b-1);
}

Measured memory_bytes: 256
/*
Author: Deep Chaklasiya
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/

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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update> data_set;
#define fbo find_by_order
#define ook order_of_key




#define int         long long
#define double      long double
#define pb          push_back
#define pf          push_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define piiii       pair<pii,pii>
#define viiii       vector<pair<pii,pii>>
#define mi          map<int,int>
#define mii         map<pii,int>
#define piii           pair<int,pair<int,int> >
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        998244353
#define PI          3.141592653589
#define bs(v,n)     binary_search(all((v)),(n))
#define lb(v,n)     lower_bound(all((v)),(n))
#define ub(v,n)     upper_bound(all((v)),(n))
#define fo(i,l,u)   for(i=l;i<u;i++)
#define rfo(i,l,u)  for(i=l;i>=u;i--)
#define allfo(s)    for(auto it=(s).begin();it!=(s).end();it++)
#define _init(b)     memset(b,-1,sizeof(b))
#define _init0(b)     memset(b,0,sizeof(b))
#define MOD         1000000007
#define ef else if





int gcd(int a, int b) {  if (a == 0)  return b; return gcd(b % a, a); }
bool mod(double a,double b) {return a/b - floor(a/b);}

int occurs(vi v,int n){
auto it=lb(v,n);auto it1=ub(v,n);int x=it1-it;return x;}

int logb(int base, int x) {
    return (log(x) / log(base));
}


template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}

void set_min(int &m,int a){
    if(m==-1||m>a)m=a;
}


signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int i,j,x,n,m,k,t;
     cin>>n;
     string s,s1;
     cin>>s;
     cin>>s1;
     for(int i=0;i<n;i++)
     {
     	cout<<s[i]<<s1[i];
	 }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define ave2(x,y) (double)((x)+(y))/2

int main(void){

	int N;
	double x;
	scanf("%d",&N);

	int *a;
	a = calloc(N,sizeof(double));

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

	for(int i=0;i<N;i++){
		for(int t=N-1;t>i;t--){
			if(a[t-1] > a[t]){
				double tmp;
				tmp = a[t-1];
				a[t-1] = a[t];
				a[t] = tmp;	
			}
		}
	}

	x = a[0];

	for(int i=1;i<N;i++){
		x = ave2(x,a[i]);
	}

	free(a);

	printf("%f\n", x);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

map<int,int> c;

int main()
{
	int n, m;
	read(n, m);
	for(;m--;){
		int a, b; read(a, b);
		if(a == 1) ++c[b];
		if(b == n) ++c[a];
	}
	int a=0;
	for(auto t:c) if(t.second == 2){ a=2; break; }
	puts("IMPOSSIBLE"+a);
	return 0;
}


Measured memory_bytes: 9600
import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt(), k = sc.nextInt();

		long ans = 0;
		for (int b = 1; b <= n; b++) {
			// a<b
			ans += Math.min(k - 1, b - 1);
			// a>=b
			// 0,1,2,3,...,b-1,0,1,2,3,..
			int len = n - b + 1;
			int cycles = len / b;
			int last = n % b;
			ans += cycles * Math.min(b, k);
			if (last != b - 1) {
				ans += Math.min(k, last + 1);
			}
		}
		if (k == 0)
			ans = 0;
		out.println(n * 1L * n - ans);
		out.close();

	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		Scanner(String fileName) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(fileName));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		String nextLine() throws IOException {
			return br.readLine();
		}

		int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		boolean ready() throws IOException {
			return br.ready();
		}

	}

}

Measured memory_bytes: 21460
n = int(input())
count = 0
for i in range(n):
  d1, d2 = map(int, input().split())
  if count > 2:
    break
  else:
    if d1 == d2:
      count += 1
    else:
      count = 0
if count > 2:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 8992
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<string>
#include<cstring>
#include<time.h>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;

#define repi(i,a,b) for(ll i = (a); i < (b); i++)
#define rep(i, n) for(ll i = 0; i < (n); ++i)

const ll MAX = 510000;
const ll MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

using P = pair<int, ll>;
struct node {
    vector<int> link;
    int mattanp;
};

vector<node> nod;
unordered_map<ull, P> mem;

P f(int ind, int parent) {
    ull skey;
    if (parent != -1) {
        skey = ind;
        skey <<= 32;
        skey |= parent;
        if (mem.find(skey) != mem.end()) return mem[skey];
    }
    vector<P> ps;
    for (int i : nod[ind].link) if (i != parent) ps.push_back(f(i, ind));
    int cc = 0;
    ll ret = 1;
    for (int i = 0; i < ps.size(); ++i)cc += ps[i].first;
    int cur = cc;
    for (int i = 0; i < ps.size(); ++i) {
        ret *= COM(cur, ps[i].first);
        cur -= ps[i].first;
        ret %= MOD;
        ret *= ps[i].second;
        ret %= MOD;
    }
    P r = P(cc + 1, ret);
    if(parent != -1) mem.insert(pair<ull, P>(skey, r));
    return r;
}

int main() {
    COMinit();
    int n;
    cin >> n;
    nod.resize(n);
    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        nod[a - 1].link.push_back(b-1);
        nod[b - 1].link.push_back(a- 1);
    }
    vector<ll> res(n);
    unordered_map<int, vector<int>> mp;
    rep(i, n) {
        if (nod[i].link.size() == 1) {
            nod[i].mattanp = nod[i].link[0];
            mp[nod[i].mattanp].push_back(i);
        }
        else nod[i].mattanp = -1;
    }
    for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
        ll val = f(itr->second[0], -1).second;
        for (int i = 0; i < itr->second.size(); ++i) res[itr->second[i]] = val;
    }
    rep(i, n) if (nod[i].mattanp == -1) res[i] = f(i, -1).second;
    rep(i, n) cout << res[i] << endl;
    return 0;
}



Measured memory_bytes: 56052
#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second 
using namespace std;

int n, m, aim, las, fa[101000], cnt[101000], used[101000], fl[101000];
pii a[101000];
long long ans;

int GF(int x){
  return x==fa[x]? x: fa[x]=GF(fa[x]);
}

int main(){
  cin>>n>>m; aim=n-1-m;
  for (int i=1;i<=n;++i){
    scanf("%d",&a[i].fi); a[i].se=fa[i]=i;
  }
  int x,y;
  for (;m--;){
    scanf("%d%d",&x,&y); ++x; ++y;
    if (GF(x)!=GF(y)) fa[GF(x)]=GF(y);
  }
  sort(a+1,a+n+1);
  las=aim*=2;
  for (int i=1;i<=n&&las;++i){
    if (!used[GF(a[i].se)]){
      used[GF(a[i].se)]=1;
      ans+=a[i].fi; ++cnt[GF(a[i].se)];
      --las; fl[i]=1;
    }
  }
  for (int i=1;i<=n&&las;++i) if (!fl[i]){
    if ((cnt[GF(a[i].se)]+1)*2<=aim){
      //printf("%d\n",a[i].se);
      ans+=a[i].fi; ++cnt[GF(a[i].se)];
      --las;
    }
  }
  if (las) return 0*puts("Impossible");
  cout<<ans;
} 

Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

string yes = "Yes";
string no = "No";

signed main() {
	int N;
	cin >> N;

	vector<int> a, b;
	inputVector(a, N);
	inputVector(b, N);

	int pool = 0;
	rep(i, N) {
		if (abs(a[i] - b[i]) % 2) {
			pool += 2;
			b[i]++;
		}
		if (a[i] < b[i]) {
			pool -= b[i] - a[i];
		} else if (a[i] > b[i]) {
			pool += (a[i] - b[i]) * 2;
		}
	}

	cout << (pool <= 0 ? yes : no) << endl;

    return 0;
}


Measured memory_bytes: 384
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        n: usize,
        mut aa: [usize; n]
    }
    

    let max = aa.iter().max().unwrap() + 1;
    let mut counts = vec![0usize; max];

    for &a in aa.iter() {
        let mut index = a;
        while index < max {
            counts[index] += 1;
            index += a;
        }
    }

    let ans = aa.iter().map(|&x| counts[x]).filter(|&x| x == 1).count();

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

Measured memory_bytes: 12804
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int N,M; cin >> N >> M;
  int ans = 0, sum = 0;
  vector<int> A(N); 
  REP(i,N){
    cin >> A[i];
    sum += A[i];
  }
  REP(i,N){
    if(A[i] * 4 * M >= sum) ans++;
  }
  if(ans >= M)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  string s;
  cin >> s;
  string ss = s;
  reverse(s.begin(),s.end());
  if(s == ss){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}
const int INF = 1e18;

signed main() {
    int N;
    cin >> N;
    map<int, int> mp;
    vi sums(N+1, 0);
    rep(i, N) {
        int a;
        cin >> a;
        sums[i+1] = sums[i]+a;
        mp[sums[i+1]]++;
    }

    int res = 0;
    for(auto &p : mp) {
        res += p.se*(p.se-1)/2;
    }
    res += mp[0];

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 14336