akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
ll gcd(ll a, ll b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}
ll lcm(ll a, ll b){
  ll g = gcd(a,b);
  return a / g * b;
}

const int INF = 1<<30;
const int MOD = 1000000007;
int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};

int main(){
  int n; cin >> n;
  vector<ll> v(n); rep(i,n) cin >> v[i];
  
  ll ans = v[0];
  for(int i = 1; i < n; i++){
    ans = ans / gcd(ans,v[i]) * v[i];
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int i;
  int s;
  int a[3] = {0};
  
  scanf("%c%c%c",&a[0],&a[1],&a[2]);

  s = a[0];
  i = 1;
  while (i < 3)
  {
    if (a[i] != s)
    {
      printf("Yes");
      return (0);
    }
    i++;
  }
  
  printf("No");
  return (0); 
}

Measured memory_bytes: 128
N = int(input())
for h in range(3501):
    for n in range(h):
        if 4 * h * n - N * (h + n) > 0 and (N * h * n) % (4 * h * n - (N * (h + n))) == 0:
            w = (N * h * n) // (4 * h * n - N * (h + n))
            print(h, n, w)
            exit()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;


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

    int n;
    cin>>n;
    string s[n];
    int t[n];
    int ans = 0;
    for(int i=0;i<n;i++){
        cin>>s[i]>>t[i];
        ans += t[i];
    }
    string x;
    cin>>x;
    for(int i=0;i<n;i++){
        ans -= t[i];
        if(s[i]==x) break;
    }
    cout <<ans<<endl;

}

Measured memory_bytes: 256
using System;

public class Program
{
	public static bool search(int[] A, int n, int key)
	{
		int i = 0;
		A[n] = key;
		while(A[i] != key) i++;
		return i != n;
	}

	public static int Main()
	{
		int i, n, q, key, sum = 0;
		int[] A = new int[10000+1];


		n = int.Parse(Console.ReadLine());
		string[] line = Console.ReadLine().Split(' ');
		for( i = 0; i < n; i++) {
			A[i] = int.Parse(line[i]);
		}

		q = int.Parse(Console.ReadLine());
		string[] strKey = Console.ReadLine().Split(' ');
		for( i = 0; i < q; i++) {
			key = int.Parse(strKey[i]);
			if (search(A, n, key)) sum++;
		}

		Console.WriteLine("{0}",sum);
		return 0;
	}
}

Measured memory_bytes: 9604
import java.util.Scanner;

public class Main {
  
  	private final static Scanner sc = new Scanner(System.in);
    public static void main (String [] args) {
      boolean klappts = true;
      String S = sc.next();
      int N = S.length();
      for(int i = 0; i < N; i++) {
      	if((i % 2 == 0 && S.charAt(i) == 'L') || (i % 2 == 1 && S.charAt(i) == 'R')) {
          klappts = false;
          break;
        }
      }
      if (klappts) {
        System.out.println("Yes");
      } else  {
        System.out.println("No");
      }
   }
}

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

int main() {
  string s;
  cin >> s;
  int a_index = -1, z_index = 0;
  int i;
  for (i = 0; i < s.length(); i++) {
    if (a_index == -1 && s.at(i) == 'A') {
      a_index = i;
    } else if (s.at(i) == 'Z') {
      z_index = i;
    }
  }
  cout << z_index - a_index + 1 << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

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

    int n;
    cin >> n;

    cout << 180 * (n - 2);

    return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

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

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#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 true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    ll N; cin >> N;
    vector<ll> A(N); REP(i,N) cin >> A[i];
    vector<ll> S(N+1,0); REP(i,N) S[i+1] = S[i] + A[i];
    ll ans = 0;
    map<ll,ll> m; m[0] = 1;
    FOR(i,1,N+1){
        if(m.find(S[i]) != m.end()){
            ans += m[S[i]];
            m[S[i]]++;
        }
        else m[S[i]] = 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 15872
<?php

class Scanner {
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next() {
        if($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext() {
        return $this->pointer < $this->count;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
}

class out {
    public static function println($str = "") {
        echo $str . PHP_EOL;
    }
}

$sc = new Scanner();
$str = $sc->next();
$str[3] = '8';
out::println($str);


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

int a[100000];
int main(){
	int n,k;
	while(cin>>n>>k,n||k){
		int sum=0,ans= -10000*100000;
		for(int i=0;i<k;i++){
			cin>>a[i];
			sum += a[i];
		}
		ans=max(ans,sum);
		for(int i=k;i<n;i++){
			sum -= a[i-k];
			cin>>a[i];
			sum += a[i];
			ans=max(ans,sum);
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1548
n = int(input())
H = list(map(int,input().split()))

C = [0 for i in range(n)]

if n == 2:
    print(abs(H[1] - H[0]))
    exit()

C[0] = 0
C[1] = abs(H[1] - H[0])
C[2] = min((C[1] + abs(H[2] - H[1])), (C[0] + abs((H[2] -H[0]))))

for i in range(2,n):
    C[i] = min((C[i-1] + abs(H[i] - H[i-1])), (C[i-2] + abs(H[i] - H[i-2])))

print(C[n-1])

Measured memory_bytes: 13980
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
  map<char, int> w;
  string s;
  cin>>s;
  for(char x: s){
    w[x]++;
  }
  bool ok = true;
  for(auto x: w){
    if(x.second%2)ok=false;
  }
  cout<<(ok? "Yes\n": "No\n");
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(){
  long long x, y, r, i;
  bool flag = false;
  scanf("%lld",&x);
  for(y = x;; y++){
    flag = false;
    for(i = 2; i <= sqrt((double)y) + 0.1; i++){
      if(y % i == 0){
        flag = true;
        break;
      }
    }
    if(!flag) break;
  }
  printf("%lld",y);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

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

		if (k * 500 >= x) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をlongで返却
	 *
	 * @return
	 */
	public static long getLong(Scanner sc) {

		return Long.parseLong(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をintで返却
	 *
	 * @return
	 */
	public static int getInt(Scanner sc) {

		return Integer.parseInt(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をStringで返却
	 *
	 * @return
	 */
	public static String getString(Scanner sc) {

		return sc.next();
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をint配列で返却
	 *
	 * @return
	 */
	public static int[] getIntArray(Scanner sc) {
		String line = "";
		// 直前にnext()を実行していると改行コードだけ取ってしまうのでその対策
		while (line.equals("")) {
			line = sc.nextLine();
		}

		String[] strArray = line.split(" ");
		int[] intArray = new int[strArray.length];
		for (int i = 0; i < strArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		return intArray;
	}

}


Measured memory_bytes: 21716
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long N = sc.nextInt();
    long sum = 0;
    for(long i = 1; i<= N; i++){
      if(i % 3!=0  && i % 5!=0 ){
        sum = sum + i;
      }
    }
    System.out.println(sum);
  }
}


Measured memory_bytes: 35812
#include<bits/stdc++.h>
using namespace std;
map<int ,bool >mark;
int main()
{
    int n;
    cin>>n;
    bool flag=0;
    for(int i=1;i<=n;i++){
        int x;
        cin>>x;
        if(mark[x]) flag=1;
        mark[x]=1;
    }
    if(flag) cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
    return 0;
}


Measured memory_bytes: 9600
#include<stdio.h>

char s[100001],l[100001];

int check(long n,int i){
	l[0]=(i%2==0)?'S':'W';
	l[1]=(i/2==0)?'S':'W';
	long j;
	for(j=1;j<n-1;j++){
		if(l[j]=='S'){
			if(s[j]=='o') l[j+1]=l[j-1];
			else l[j+1]=(l[j-1]=='W')?'S':'W';
		}else{
			if(s[j]=='x') l[j+1]=l[j-1];
			else l[j+1]=(l[j-1]=='W')?'S':'W';
		}
	}
	if(l[n-1]=='S'){
		if(s[n-1]=='o'){
			if(l[0]!=l[n-2]) return 0;
		}else{
			if(l[0]==l[n-2]) return 0;
		}
	}else{
		if(s[n-1]=='x'){
			if(l[0]!=l[n-2]) return 0;
		}else{
			if(l[0]==l[n-2]) return 0;
		}
	}
	if(l[0]=='S'){
		if(s[0]=='o'){
			if(l[1]!=l[n-1]) return 0;
		}else{
			if(l[1]==l[n-1]) return 0;
		}
	}else{
		if(s[0]=='x'){
			if(l[1]!=l[n-1]) return 0;
		}else{
			if(l[1]==l[n-1]) return 0;
		}
	}
	l[n]='\0';
	return 1;
}

int main(int argc, char const *argv[]) {
	long n;
	int i;
	scanf("%ld",&n);
	scanf("%s",s);
	for(i=0;i<4;i++){
		if(check(n,i)) i=4;
	}
	if(i==4) printf("-1\n");
	else printf("%s\n",l);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <map>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

template <class T>
vector<T> factorize(T n) {
  vector<T> res;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      res.push_back(i);
      while (n % i == 0) n /= i;
    }
  }

  if (n != 1) res.push_back(n);
  return res;
}

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

  vector<ll> res = factorize(n);
  
  int m = res.size(), ans = 0;
  for (int bit = 1; bit < (1 << m); ++bit) {
    int pop_count = __builtin_popcount(bit);
    int mul = 1;
    for (int i = 0; i < m; ++i) {
      if (bit >> i & 1) mul *= res[i];
    }
    if (pop_count % 2 == 1) ans += n / mul;
    else ans -= n / mul;
  }

  ans = n - ans;
  cout << ans << endl;
}



Measured memory_bytes: 3148
def examB():
    A, B = LI()
    IL = [0]*1000
    for i in range(999):
        IL[i+1] = IL[i]+(i+1)
    ans = IL[B-A] - B
    print(ans)


import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()


Measured memory_bytes: 38384
#include <stdio.h>
 
int main()
{
  int a[100000], b[50000];
  int i, right, left, center, n, q, count=0;
  
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&a[i]);
  }
  
  scanf("%d", &q);
  for(i=0; i<q; i++){
    scanf("%d", &b[i]);
  }
  
  for(i=0; i<q; i++){
    right = n;
    left = 0;
    while(left<=right){
      center = (right + left)/2;
      if(a[center] == b[i]) {
		count++;
		break;
      }
      else if(a[center] < b[i])
		left = center + 1;
      else
		right = center - 1;
    }
  }
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    string s;
    cin >> s;
    int n = s.size();
    int cur = 0;
    vector<int> dp(n + 1, INF);
    vector<int> mn(1 << 26, INF);
    dp[0] = 0;
    mn[0] = 0;
    for (int i = 0; i < n; i++) {
        cur ^= 1 << (s[i] - 'a');
        dp[i + 1] = min(dp[i + 1], mn[cur] + 1);
        for (int c = 0; c < 26; c++) {
            int nxt = cur ^ (1 << c);
            dp[i + 1] = min(dp[i + 1], mn[nxt] + 1);
        }
        mn[cur] = min(mn[cur], dp[i + 1]);
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 266584
#include <iostream>
#include <vector>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <numeric>
#include <iterator>

using namespace std;

namespace {

}
#if 0
int Work2()
{
	int N;
	cin >> N;

	vector<int> a(N, 0);

	int cnt = 0;
	int maxV = 0;
	int minV = 0;
	for (int i = 0; i < N; ++i){
		int j;
		cin >> j;
		a[i] = j;
		maxV = max(maxV, j);
		minV = min(minV, j);
		// if (j - 1 == )
		
	}
	int maxC = 0;
	for (int i = minV - 1; i <= maxV; ++i){
		int cnt = 0;
		for (int j = 0; j < N; ++j){
			if (a[j] == i || (a[j] - 1 == i) || (a[j] + 1 == i)){
				++cnt;
			}
		}
		maxC = max(maxC, cnt);
	}
	cout << maxC << endl;
	//max = max(a.begin(), a.end());


	return 0;
}
#endif
int main()
{
	int N;
	cin >> N;

	vector<int> a(N, 0);
	map<int, int> num;

	// int cnt = 0;
	// int maxV = 0;
	// int minV = 0;
	for (int i = 0; i < N; ++i){
		int j;
		cin >> j;

		for (int k = -1; k <= 1; ++k){
			int curNum = j + k;
			if (num.count(curNum) == 0){
				num[curNum] = 1;
			}
			else{
				++num[curNum];
			}
		}
	}

	int maxC = 0;
	for (auto& elem : num){
		maxC = max(maxC, elem.second);

	}
	
	cout << maxC << endl;
	//max = max(a.begin(), a.end());


	return 0;
}

Measured memory_bytes: 7948
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e5 * 3, INF = 1e9 * 100;
vector<vector<ll>> gr;

bool used[SIZE];
vector<ll> vec, ret;

ll dfs(int v) {
    used[v] = 1;

    ll cnt = 0, s = 0;
    vector<ll> vals;
    if (gr[v].size() == 1) {
        ret[v] = vec[v];
        return vec[v];
    }
    for (auto to : gr[v]) {
        if (!used[to]) {
            ll vl = dfs(to);
            if (vl == INF) {
                ret[v] = INF;
                return INF;
            }
            vals.push_back(vl);
            s += vl;
            cnt++;
        }
    }

    sort(vals.rbegin(), vals.rend());
    if (s < vec[v]) {
        ret[v] = INF;
        return INF;
    }
    ll mn = 0;
    if (vals[0] <= (s - vals[0])) {
        mn = s / 2 + (s % 2);
    }
    else {
        ll lft = vals[0] - (s - vals[0]);
        mn = (s - vals[0]) + lft;
    }

    
    if (mn > vec[v]) {
        ret[v] = INF;
        return INF;
    }

    ll dif = s - vec[v];
    ll needed = s - dif * 2;

    ret[v] = needed;
    return needed;
}
int main() {
    fastInp;
    ll n;
    cin >> n;
    ret.resize(n);

    vec.resize(n);
    for (int i = 0; i < n; i++) cin >> vec[i];

    gr.resize(n);
    for (int i = 0; i < n - 1; i++) {
        ll u, v;
        cin >> u >> v;
        u--; v--;
        gr[u].push_back(v);
        gr[v].push_back(u);
    }

    if (n == 2) {
        if (vec[0] == vec[1]) {
            cout << "YES";
        } else {
            cout << "NO";
        }
        return 0;
    }
    for (int i = 0; i < n; i++) {
        if (gr[i].size() != 1) {
            if (dfs(i) == 0) {
                cout << "YES";
            }
            else {
                cout << "NO";
            }
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 20948
n = int(input())
words = {}
sum_cnt = 0

while n > 0:
    word = sorted(input())
    word = "".join(word)
    if word in words:
        sum_cnt += words[word]
        words[word] += 1
    else:
        words[word] = 1
    n -= 1

print(int(sum_cnt))

Measured memory_bytes: 17852
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    ll sq=0;
    int cnt=1;
    ll w=0,h=0;
    for(int i=a.size(); i>=0; i--){
        //次の値がそれまでの値と同じか?
        if(a[i]==a[i-1]){
            cnt++;
        }else{
            if(cnt>=2 && cnt<=3){
                swap(w,h);
                w=a[i];
                sq=max(sq,w*h);
            }else if(cnt >= 4){
                if(w!=0){
                    swap(w,h);
                    w=a[i];
                    sq=max(sq,w*h);
                }else{
                    w=a[i];
                    h=a[i];
                    sq=max(sq,w*h);
                }
            }
            cnt=1;
        }
    }
    cout << sq << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

const ld eps = 1.0e-18; // 許容される誤差

ld mysqrtl(ld x)
{
  ld a = sqrt((double)x); // 近似値
  do {
    a = (a + x/a) / 2.0L;
  } while (fabsl(x - a*a) > eps);
  return a;
}

int main() {
  ld a,b,c;
  cin >> a >> b >> c;
  if(a+2*sqrt(a*b)+b<c){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;


#define REP(i,n)	for(int i=0;i<(n);++i)
#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)


#define INF 		2000000007
#define MOD			998244353

#define MAX 		100005

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;



#define FAVOR(N,M)	(((N)/(M))==((N)%(M)))

int main(){
	ll N;	cin >> N;
	ull cnt = 0;
	
	if(N==1){
		cout << 0 << endl;return 0;
	}
	else if(FAVOR(N,N-1))cnt += N-1;
	if(N==2){
		cout << 0 << endl;return 0;
	}
	else if(N%2==0){
		if(FAVOR(N,N/2-1))cnt += N/2-1;
	}
	for(ll i=3;(i*i)<=N;++i){
		if(N%i==0){
			if(FAVOR(N,i-1))cnt += i-1;
			if(FAVOR(N,N/i-1))cnt += N/i-1;
		}
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <climits>

using namespace std;

template<typename T> 
void show(T a){
  for(auto i : a){ cout << i << " "; }
  cout << endl;
}


int main(int argc, char *argv[]){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  
  string s;
  cin >> s;
  
  int res = INT_MAX;
  for(int i = 0; i < s.size()-2; i++){
    int tmp = stoi(s.substr(i, 3));
    tmp = 753 - tmp;
    tmp = tmp > 0 ? tmp : -tmp;
    if(tmp < res) res = tmp;
  }
  cout << res << endl;

}


Measured memory_bytes: 256
//package Atcoder;
import java.util.*;
import java.io.*;
public class Main
{
	static final int mod=(int)1e9+7;
	static final int inf=(int)1e9;
	static final long INF=(long)1e18;
	public static void main(String[] args)
	{
		FastScanner fs=new FastScanner();
		int n=fs.nextInt();
		int m=fs.nextInt();
		if(n==m)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}
class FastScanner 
{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		public String next() 
		{
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
			
		}
		
		long pow(long x,long n)
		{
			long res=1;
			while(n>0)
			{
			   	if(n%2!=0)
			   	{
			   		res=(res*x);n--;
			   	}
			   	else
			   	{
			   		x=(x*x);n/=2;
			   	}
			}
			return res;
		}
		int gcd(int a,int b)
		{
			if(b==0)
			{
				return a;
			}
			return gcd(b,a%b);
		}
		long longgcd(long a,long b)
		{
			if(b==0)
			{
				return a;
			}
			return longgcd(b,a%b);
		}
		int[] sort(int arr[])
		{
			ArrayList<Integer> list = new ArrayList<Integer>();
			for(int i:arr)list.add(i);
			Collections.sort(list);
			for(int i=0;i<arr.length;i++)
			{
				arr[i]=list.get(i);
			}
			return arr;
		}
		char[] charsort(char arr[])
	        {
	    	ArrayList<Character> list = new ArrayList<>();
	    	for(char c:arr)list.add(c);
	    	Collections.sort(list);
	    	for(int i=0;i<list.size();i++)
	    	{
	    		arr[i]=list.get(i);
	    	}
	    	return arr;
	        }
		long[] longsort(long arr[])
		{
			ArrayList<Long> list = new ArrayList<Long>();
			for(long i:arr)list.add(i);
			Collections.sort(list);
			for(int i=0;i<arr.length;i++)
			{
				arr[i]=list.get(i);
			}
			return arr;
		}
		public int nextInt() 
		{
			return Integer.parseInt(next());
		}
		public int[] readArray(int n)
		{
			int[] arr=new int[n];
			for (int i=0; i<n; i++) arr[i]=nextInt();
			return arr;
		}	
		public long nextLong()
		{
			return Long.parseLong(next());
		}
		public long[] longreadArray(int n) 
		{
			long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextLong();
			return a;
		}
}

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

int main() {
  int N, H, W, ans = 0;
  cin >> N >> H >> W;
  int A[N], B[N];
  for(int i = 0; i < N; i++) {
    cin >> A[N] >> B[N];
    if( H <= A[N] && W <= B[N]) ans++;
  }
  cout << ans;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=110;
int b[N],n,ans=0;
int main() {
	rd(n);
	for(int i=1;i<n;++i) rd(b[i]);
	b[0]=b[n]=1e9;
	for(int i=1;i<=n;++i) ans+=min(b[i],b[i-1]);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

int main() {
    int hh,ww,h,w;
    cin >> hh >> ww >> h >> w;
    if (hh % h == 0 && ww % w == 0) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    REP(i,0,hh) {
        REP(j,0,ww) {
            if (j) cout << " ";
            if (i % h == 0 && j % w == 0)           cout <<  1000000000 - 1;
            else if (i % h == h - 1 && j % w == w - 1)   cout << -1000000000;
            else cout << 0;
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;

long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcd(long long a,long long b){return a*b / gcd(a,b) / gcd(a,b);}
int main()
{
	int A,B,C,D;
	cin>>A>>B>>C>>D;

	bool turn = true;
	while(A>0 && C > 0)
	{
		if(turn)
		{
			C-=B;
		}
		else
		{
			A-=D;
		}
		turn = !turn;
	}

	if(A>0)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
 using namespace std;
 #define rep(i,N) for(int i=0;i<int(N);++i)
 using ll = long long;
 const int MOD = 1e9 + 7;
 
 int main(){
     int k;
     cin >> k;
     if(k==1) cout << "ACL" << endl;
     if(k==2) cout << "ACLACL" << endl;
     if(k==3) cout << "ACLACLACL" << endl;
     if(k==4) cout << "ACLACLACLACL" << endl;
     if(k==5) cout << "ACLACLACLACLACL" << endl;
     return 0;
 }


Measured memory_bytes: 3588
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        while (n-- > 0) {
            int a=sc.nextInt(),b=sc.nextInt(),c=sc.nextInt(),d=sc.nextInt();
            if(c>=5&&d>=2) {
                System.out.println((a*c+b*d)*8/10);
            }else {
                System.out.println(Math.min(a*c+b*d,(a*(c<5?5:c)+b*(d<2?2:d))*8/10 ));
            }
        }
    }
}



Measured memory_bytes: 32120
n=int(input())
e=[]
o=[]
v=list(map(int,input().split()))
for i in range(n):
  if i%2==0:
    o.append(v[i])
  else:
    e.append(v[i])
from collections import Counter
o=Counter(o)
e=Counter(e)
o=sorted(o.items(),key=lambda x:x[1],reverse=True)
e=sorted(e.items(),key=lambda x:x[1],reverse=True)

if o[0][0]!=e[0][0]:
  print(n-o[0][1]-e[0][1])
else:
  if o[0][1]==n//2 and e[0][1]==n//2:
    print(n//2)
  elif o[0][1]==n//2:
    print(n//2-e[1][1])
  elif e[0][1]==n//2:
    print(n//2-o[1][1])
  else:
    print(min(n-o[0][1]-e[1][1],n-o[1][1]-e[0][1]))

Measured memory_bytes: 96384
object Main{
    def main(args: Array[String]): Unit ={
        var in = scala.io.StdIn.readLine().split(" ").map(_.toInt)
        scala.util.Sorting.quickSort(in)
        in.dropRight(1).foreach(item =>
            print(item + " ")
        )
        println(in.last)
    }
}

Measured memory_bytes: 43760
// https://ei1333.github.io/luzhiled/
// http://beet-aizu.hatenablog.com/entry/2017/01/04/113233
// http://www.prefield.com/algorithm/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
using vs = vector<string>;
using vb = vector<bool>;
using vvl = vector<vector<ll>>;
using vvd = vector<vector<ld>>;
using vvs = vector<vector<string>>;
using vvb = vector<vector<bool>>;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;
using Graph = vector<vector<ll>>;
const ll INF = 1LL << 60;
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
#define tl 1'000'000'007
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REREP(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define REFOR(i, n, a) for (ll i = n; i >= a; i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define debug cout << "line : " << __LINE__ << " debug" << endl;
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ind(...) long double __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << endl;} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#define in1(A) REP(i,A.size()) in(A[i]);
#define in2(A,B) REP(i,A.size()) in(A[i],B[i]);
#define in3(s,t,u) REP(i,sz(s)){in(s[i] , t[i] , u[i]);}
#define in4(s,t,u,v) REP(i,sz(s)){in(s[i] , t[i] , u[i] , v[i]);}
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
struct Point{ ld x,y; };
ld dist(Point a, Point b){return sqrt(abs(a.x-b.x)*abs(a.x-b.x)+abs(a.y-b.y)*abs(a.y-b.y));} // ２点間の距離 
ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b;} 
ll fact(ll n){ if(n < 2) return 1; return (n * fact(n-1))%tl; } //階乗
inline ll updiv(ll a,ll b){ return (a + b - 1) / b; } //切り上げ
template<typename T,typename U>ll ceil(T a,U b){return (a + b - 1) / b;}
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
//-------------------------------------------------------------------------------------------------
int main(){
    init();
    inl(n);
    out(n/500*1000+(n%500)/5*5);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define vll vector<long long>
#define ll long long
#define pii pair<int,int>
const int mod=1e9+7;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("inputf.txt","r",stdin);
    freopen("outputf.txt","w",stdout);
#endif
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    int dp[n]={0};
    dp[1]=abs(a[0]-a[1]);
    for(int i=2;i<k && i<n;i++){
        dp[i]=INT_MAX;
        for(int j=i-1;j>=0;j--){
            dp[i]=min(dp[j]+abs(a[j]-a[i]),dp[i]);
        }
    }
    for(int i=k;i<n;i++){
        dp[i]=INT_MAX;
        for(int j=i-1,z=0;z<k;z++,j--){
            dp[i]=min(dp[j]+abs(a[j]-a[i]),dp[i]);
        }
    }
    cout<<dp[n-1]<<"\n";
    return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;


int main(){
    int a,b,c;cin >>a>>b>>c;
    if(b-a==c-b)puts("YES");
    else puts("NO");
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    string S;
    cin >> S;
    int len = S.size();
    bool none = true;
    for (char x = 'a'; x <= 'z'; x++){
        bool ans = true;
        rep(i,len){
            if (S[i] == x){
                ans = false;
            }
        }
        if (ans){
            cout << x << endl;
            none = false;
            break;
        }
    }
    if (none){
        cout << "None" << endl;
    }
}


Measured memory_bytes: 512
# 2019-11-12 22:11:12(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    H, W, h, w = [int(x) for x in sys.stdin.read().split()]

    ans = H * W - (h * W + (H - h) * w)
    print(ans)



if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll w[100009],b[100009],mod=1e9+7;
vector<int>v[100009];
void dfs(int x,int par)
{
    b[x]=1;w[x]=1;
    for(int i=0;i<v[x].size();i++)
    {
        int y=v[x][i];
        if(y==par)continue;
        dfs(y,x);
        b[x]*=w[y];
        b[x]%=mod;
        w[x]*=((w[y]+b[y]));
        w[x]%=mod;
    }
    return;
}
int n;
int main()
{
    cin>>n;
    int x,y;
    for(int i=0;i<n-1;i++)
    {
        cin>>x>>y;
        x--;y--;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    dfs(0,0);
    cout<<(w[0]+b[0])%mod;
}


Measured memory_bytes: 14208
#include <bits/stdc++.h>
using namespace std;
//debug
#ifdef grief
#define debug(...) do{\
	fprintf(stderr , "%s - %d : (%s) = " , __PRETTY_FUNCTION__ , __LINE__ , #__VA_ARGS__ );\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> 				void _DO(I&&x){	cerr<<x<<endl;	}
template<typename I,typename...T>	void _DO(I&&x,T&&...tail){	cerr<<x<<" , ";	_DO(tail...);	}
template<typename _a,typename _b> 	ostream& operator << (ostream &_s,const pair<_a,_b> &_p)
{	return _s<<'('<<_p.first<<','<<_p.second<<')';	}
#define IOS
#else
#define debug(...)
#define IOS do{ios_base::sync_with_stdio(0); cin.tie(0);}while(0);
#endif
//type
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef priority_queue<pll,vector<pll>,greater<pll> > heap;
//macro
#define SZ(x) ((ll)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define stp setprecision(30)<<fixed
const ll INF=0x3f3f3f3f3f3f3f3f;
const int NF=0x3f3f3f3f;
const ll MAX=1e5+5,Mlg=__lg(MAX)+2;
const ll MOD=1e9+7;
// ready~ go!
// let's coding and have fun!
// I can't solve this problem!
string s;
vector<char> v;
bool dfs(int now=0,int id=0){
	debug(now,id);
	if(id==4){
		if(now==7)	return 1;
		return 0;
	}
	v.eb('+');
	if(dfs(now+s[id],id+1))	return 1;
	v.pop_back();
	v.eb('-');
	if(dfs(now-s[id],id+1))	return 1;
	v.pop_back();
	return 0;
}
int main(){
	IOS
	cin>>s;
	for(int i=0;i<4;i++)	s[i]-='0';
	dfs(s[0],1);
	for(int i=0;i<4;i++)	s[i]+='0';
	cout<<s[0]<<v[0]<<s[1]<<v[1]<<s[2]<<v[2]<<s[3]<<"=7\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;

int main()
{
  int m;
  for(;cin>>m,m;)
    {
      vector<pair<int,int> >data;
      for(int i=0;i<m;i++)
	{
	  int num;
	  cin>>num;
	  int point=0;
	  vector<int> st;

	  //bool input;
	  for(int x=0;x<9;x++)
	    {
	      int tmp;
	      cin>>tmp;
	      point+=tmp;
	      for(int jj=0;jj<st.size();jj++)
		{
		  if(st[jj]>0)
		    point+=tmp;
		  st[jj]--;
		}
	      if(tmp>=10)
		st.push_back(2);
	      else
		{
		  int tmp2;
		  cin>>tmp2;
		  point+=tmp2;
		  for(int jj=0;jj<st.size();jj++)
		    {
		      if(st[jj]>0)
			point+=tmp2;
		      st[jj]--;
		    }
		  if(tmp+tmp2>=10)
		    st.push_back(1);
		}
	    }
	  //last_set
	  int tmp1,tmp2,tmp3;
	  cin>>tmp1;
	  point+=tmp1;
	  for(int jj=0;jj<st.size();jj++)
	    {
	      if(st[jj]>0)
		point+=tmp1;
	      st[jj]--;
	    }
	  //	  if(tmp1>=10)
	  //	    st.push_back(2);

	  cin>>tmp2;
	  point+=tmp2;
	  for(int jj=0;jj<st.size();jj++)
	    {
	      if(st[jj]>0)
		point+=tmp2;
	      st[jj]--;
	    }
	  //	  if(tmp2>=10)
	  //    st.push_back(2);
	  //  else if(tmp1+tmp2>=10)
	  //  st.push_back(1);

	  if(tmp1+tmp2>=10)
	    {
	      cin>>tmp3;
	      point+=tmp3;
	      for(int jj=0;jj<st.size();jj++)
		{
		  if(st[jj]>0)
		    point+=tmp3;
		  st[jj]--;
		}
	    }

	  data.push_back(make_pair(-point,num));
	}


      sort(data.begin(),data.end());
      for(int i=0;i<m;i++)
	  cout<<data[i].second<<" "<<-data[i].first<<endl;
    }
}

Measured memory_bytes: 1220
import heapq as hq
def inp():
	return (int(input()))


def inlt():
	return (list(map(int,input().split())))


def insr():
	s=input()
	return (list(s[:len(s)]))


def invr():
	return (map(int,input().split()))


def subset_sum_count(arr,n,sum):
	dp=[[0 for _ in range(sum+1)] for _ in range(n+1)]
	for i in range(n+1):
		for j in range(sum+1):
			if j==0:
				dp[i][j]=1
			elif arr[i-1]<=j:
				dp[i][j]=dp[i-1][j-arr[i-1]]+dp[i-1][j]
			else:
				dp[i][j]=dp[i-1][j]
	return dp[n][sum]


def prefix(a):
	pre=[]
	pre.append(a[0])
	for i in range(1,len(a)):
		pre.append(pre[i-1]+a[i])
	return pre

def str_to_integer_list(n):
	a=[]
	for i in range(len(n)):
		a.append(int(n[i]))
	return a
def list_to_str(l):
	s=""
	for i in l:
		s+=str(i)
	return s
def binarySearch(arr,low,high,x):
	if (high>=low):
		mid=low+(high-low)//2
		if x==arr[mid]:
			return (mid)
		elif (x>arr[mid]):
			return binarySearch(arr,(mid+1),high,x)
		else:
			return binarySearch(arr,low,(mid-1),x)
	
	return -1


def right_shift(a,s):
	return a[s:]+a[:s]


def dijkstra(s,N,E):
	visited=set()
	dist={}
	for i in range(1,N+1):
		dist[i]=1<<29
	queue=[(dist[i],i) for i in range(1,N+1)]
	hq.heappush(queue,(0,s))
	dist[s]=0
	while queue:
		d,u=hq.heappop(queue)
		if u in visited:
			continue
		#Relax all the neighbours of u
		for t in E[u]:
			v,r=t
			if dist[v]>d+r:
				dist[v]=d+r
				hq.heappush(queue,(dist[v],v))
		#Node u has been processed
		visited.add(u)
	return dist


def path(start,end,parent):
	path=[end]
	while path[-1]!=start:
		path.append(parent[path[-1]])
	path.reverse()
	return path


def bfs(graph,start,end):
	parent={}
	queue=[]
	queue.append(start)
	while queue:
		node=queue.pop(0)
		if node==end:
			return path(start,end,parent)
		for next in graph.get(node,[]):
			if node not in queue:
				parent[next]=node
				queue.append(next)


'''for _ in range(int(input())):
	n,m=list(map(int,input().split()))
	graph=[[]for _ in range(n+1)]
	distance=[-1]*(n+1)
	visited=[False]*(n+1)
	for _ in range(m):
		x,y=list(map(int,input().split()))
		graph[x].append(y)
		graph[y].append(x)'''
'''T = int(input())
for i in range(0, T):
	N, M = map(int, input().split(' '))
	graph = {}
	for j in range(1, N+1):
		graph[j] = []
	for j in range(0, M):
		x, y, r = map(int, input().split(' '))
		graph[x].append((y,r))
		graph[y].append((x,r))'''
n=int(input())
res=n+n**2+n**3
print(res)



Measured memory_bytes: 62956
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define fir first
#define sec second
#define PB push_back
#define MP make_pair
#define ll long long
using namespace std;
int main(){
    int n,k;
    int x[100100];
    int t;
    cin>>t;
    while(t--){
        cin>>n>>k;
        REP(i,n)cin>>x[i];
        vector<int>btw;
        REP(i,n-1)btw.PB(x[i+1]-x[i]);
        sort(ALL(btw));
        int sum=0;
        REP(i,n-k)sum+=btw[i];
        cout<<sum<<endl;
    }
}

Measured memory_bytes: 4264
#include <bits/stdc++.h>
using namespace std;
int n,m,c,i;
char s[100100];
int main() {
  scanf("%s",s);
  n=strlen(s);
  scanf("%d",&m);
  for (i=0; i<n-1; i++) {
    c=(26-(s[i]-'a'))%26;
    if (c<=m) { m-=c; s[i]='a'; }
  }
  s[n-1]='a'+((s[i]-'a')+m)%26;
  puts(s);
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  int c = 0, o, x;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    o = 0;
    x = i;
    while (x != 0) {
      x /= 10;
      o++;
    }
    if (o % 2 != 0) {
      c++;
    }
  }
  cout << c;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;
int main()
{
	int n,m,t;
	long long sum=0,disc=0;
	cin>>n>>m;
	priority_queue<long long> cost;
	for(int i=0;i<n;i++){
		cin>>t;
		sum+=t;
		cost.push(t);
	}
	while(m--){
		t=cost.top()/2;
		disc+=cost.top()-t;
		cost.pop();
		cost.push(t); 
	}
	cout<<sum-disc;
}

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

dp = [1000005]*n
dp[0] = 0

for i in range(n):
    if i+1 >= n:
        break
    dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i+1]))
    if i+2 >= n:
        break
    dp[i + 2] = dp[i] + abs(h[i] - h[i + 2])

print(dp[n-1])

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


int main(){
	int n;
	cin >> n;
	vector<int> nums(n);

	for (int i = 0; i < n; i++) cin >> nums[i];

	vector<int> left(n);

	left[0] = -1;

	for (int i = 1; i < n; i++) left[i] = max(left[i - 1], nums[i - 1]);

	vector<int> right(n);

	right[n - 1] = -1;

	for (int i = n - 2; i >= 0; i--) {
		right[i] = max(right[i + 1], nums[i + 1]);
	}

	for (int i = 0; i < n; i++) {
		cout << max(left[i], right[i]) << endl;
	}
}

Measured memory_bytes: 3968
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <functional>
#include <utility>
#include <unordered_map>
#define INF 2147483647
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
// a + b = nK
// b + c = n'K
// c + a = n''K
// 2a + 2b + 2c = (n + n' + n'')K

// b = nK - a
// b + c = n'K
// c = n''K - a

int main() {
	int N, K;
	cin >> N >> K;

	ll ans = 0;

	if (K < 500) {
		vector <ll> a(K, 0);
		for (int i = 1; i <= N; i++) a[i % K]++;
		for (int i = 0; i < K; i++) {
			for (int j = 0; j < K; j++) {
				for (int k = 0; k < K; k++) {
					if ((i + j) % K == 0 && (j + k) % K == 0 && (k + i) % K == 0) {
						ans += a[i] * a[j] * a[k];
					}
				}
			}
		}
	}
	else {
		for (int i = 1; i * K <= N * 2; i++) { // n
			for (int j = 1; j * K <= N * 2; j++) { // n'
				for (int k = 1; k * K <= N * 2; k++) { // n''
					int a = (i + j + k)*K - 2 * j * K;
					int b = (i + j + k)*K - 2 * k * K;
					int c = (i + j + k)*K - 2 * i * K;
					if (a <= 0 || a % 2 != 0 || b <= 0 || b % 2 != 0 || c <= 0 || c % 2 != 0)continue;
					if (a / 2 > N || b / 2 > N || c / 2 > N)continue;
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define CLR(x) memset(x,0,sizeof x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 100000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f
typedef long long ll;
//orz yht
using namespace std;
string i_s(int x){
	if(x==0)
	return "0";
	string ret="";
	while(x){
		ret=ret+(char)(x%10+'0');
		x/=10;
	}
	reverse(ret.begin(),ret.end());
	return ret;
}
string add(string a,string b){
	if(a=="")
	a="0";
	if(b=="")
	b="0";
	if(a.length()<b.length())
	swap(a,b);
	while(b.length()<a.length()){
		b='0'+b;
	}
	for(int i=0;i<a.length();i++){
		a[i]=a[i]+(b[i]-'0');
	}
	bool big=false;
	for(int i=a.length()-1;i>=0;i--){
		if(big){
			a[i]++;
		}
		big=false;
		if(a[i]>'9'){
			a[i]=a[i]-10;
			big=true;
		}
	}
	if(big)
	a='1'+a;
	return a;
}
string mul(string a,string b){
	vector<int> va,vb;
	if(a=="0" || b=="0")
	return "0";
	string ans;
	for(int i=0;i<a.length();i++){
		va.push_back(a[i]-'0');
	}
	for(int i=0;i<b.length();i++){
		vb.push_back(b[i]-'0');
	}
	reverse(va.begin(),va.end());
	reverse(vb.begin(),vb.end());
	vector<int> res;
	res.clear();
	res.resize(1005);
	for(int i=0;i<a.length();i++){
		for(int j=0;j<b.length();j++){
			res[i+j]+=(va[i]*vb[j]);
		}
	}
	for(int i=0;i<1005;i++){
		if(res[i]>9){
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	for(int i=0;i<1005;i++){
		ans+=(res[i]+'0');
	}
	reverse(ans.begin(),ans.end());
	int k=0;
	while(ans[k]=='0'){
		k++;
	}
	ans=ans.substr(k);
	return ans;
}
bool is_prime(int n){
	if(n<2)
    return false;
    for(int i=2;i*i<=n;i++)
    if(n%i==0)
    return false;
    return true;
}
int n,a[100005],sol1,sol2;
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	cin>>n;
	for(int i=0;i<n;i++)
	cin>>a[i];
	sort(a,a+n);
	for(int i=0;i<n-1;i++){
		if(a[i]==a[i+1]){
			sol2=sol1;
			sol1=a[i];
			i++;
		}
	}
	printf("%lld",1ll*sol1*sol2);
	//system("pause");
	return 0;
}

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

int main(){
  ll n; cin >> n;
  map<string, ll> m;
  rep(i,n){
    string s; cin >> s;
    sort(s.begin(),s.end());
    if(m.count(s)>0) m.at(s)+=1;
    else m.insert(make_pair(s,1));
  }
  ll ans=0;
  for(auto p: m){
    ans += p.second *(p.second - 1) /2;
  }
  cout << ans;

}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

int main(int argc, char **argv) {
	ll n, a;
	cin >> n;
	ll res = 0;
	REP(i, n) {
		cin >> a;
		while (a % 2 == 0) {
			a /= 2;
			++res;
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
  int n;
  std::cin >> n;
  int s = 0, result = 0;
  for (int i = 0; i < n; ++i) {
    int a;
    std::cin >> a;
    if (a)
      ++s;
    else {
      result = std::max(result, s);
      s = 0;
    }
  }
  result = std::max(result, s);

  std::cout << result + 1 << std::endl;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int h[25];
int m;
int ans;
int main(void){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>h[i];
        if(h[i]>=m) ans++;
        m=max(m,h[i]);
    }
    cout<<ans<<endl;

}



Measured memory_bytes: 3556