akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define VIZ {printf("digraph G{\n"); for(int i=1;i<=n;i++) for es(i,e) printf("%d->%d;\n",i,vb[e]); puts("}");}
#define VIZ2 {printf("graph G{\n"); for(int i=1;i<=n;i++) for es(i,e) if(vb[e]>=i)printf("%d--%d;\n",i,vb[e]); puts("}");}
#define SZ 666666
int n,a[3][SZ];
struct bcj
{
int ff[SZ];
int gf(int x) {return ff[x]?ff[x]=gf(ff[x]):x;}
bool uni(int a,int b)
{
	int ga=gf(a),gb=gf(b);
	if(ga^gb) ff[ga]=gb;
	else return 0;
	return 1;
}
}b[2];
int main()
{
	scanf("%d",&n);
	for(int j=0;j<3;++j)
		for(int i=1;i<=n;++i)
			scanf("%d",&a[j][i]);
	int c[2][2];
	memset(c,0,sizeof c);
	for(int i=1;i<=n;++i)
	{
		int t=0;
		if(a[0][i]+1==a[1][i]&&a[1][i]+1==a[2][i])
			t=0;
		else
		if(a[0][i]-1==a[1][i]&&a[1][i]-1==a[2][i])
			t=1;
		else
		{
			puts("No");
			return 0;
		}
		int r=min(a[0][i],min(a[1][i],a[2][i]))/3+1;
		if((i-r)&1)
		{
			puts("No");
			return 0;
		}
		if(b[i&1].uni(i,r)) c[i&1][0]++;
		if(t) ++c[i&1][1];
	}
	c[0][0]&=1; c[1][1]&=1; c[1][0]&=1; c[0][1]&=1;
	if(c[0][0]!=c[1][1]||c[1][0]!=c[0][1])
		puts("No");
	else puts("Yes");
}


Measured memory_bytes: 10880
#include <cstdio>
#include <algorithm>
using namespace std;

int H,W,x,y,z;
int cnt[30];
char a[111][111];

bool chk(){
	if(H%2==0&&W%2==0){
		return y==0&&z==0;
	}
	if(H%2==1&&W%2==0)swap(H,W);
	if(H%2==0&&W%2==1){
		x -= (W-1)*H/4;
		if(x<0)return false;
		y += x*2;
		y -= H/2;
		if(y<0)return false;
		z += y*2;
		return z==0;
	}
	x -= (H-1)*(W-1)/4;
	if(x<0)return false;
	y += x*2;
	y -= (H+W-2)/2;
	if(y<0)return false;
	z += y*2;
	return z==1;
}

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

	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			cnt[a[i][j]-'a']++;
		}
	}

	for(int i=0;i<26;i++){
		x += cnt[i]/4;cnt[i]%=4;
		y += cnt[i]/2;cnt[i]%=2;
		z += cnt[i];
	}

	if(chk()){
		puts("Yes");
	}else{
		puts("No");
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include<map>

using namespace std;

int main(int argc, char const *argv[])
{

    int N;
    map<string, int> mp;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        string S;
        cin >> S;
        mp[S]++;
    }

    int maxx = 0;
    for (auto &x : mp)
    {
        if(maxx<x.second){
            maxx = x.second;
        }
    }

    for (auto &x : mp)
    {
        if (x.second==maxx)
        {
            cout << x.first << endl;
        }
        
    }
    
    

}


Measured memory_bytes: 25216
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }
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;
}

#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>=0;--i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;


typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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


    int N;
    cin >> N;
    vs s(N);
    REP(i,N) cin >> s[i];

    int ans = 0;
    for (string str : s) {
        REP(i,str.length()-1) if (str[i] == 'A' and str[i+1] == 'B') ans++;
    }

    int num_endA = 0;
    int num_beginB = 0;
    int num_endA_and_beginB  = 0;
    for (string str : s) {
        if (str[str.length()-1] == 'A' and str[0             ] != 'B') {
            num_endA++;
            //cout << "A: " + str << endl;
        }
        if (str[0             ] == 'B' and str[str.length()-1] != 'A') {
            num_beginB++;
            //cout << "B: " + str << endl;
        }
        if (str[str.length()-1] == 'A' and str[0             ] == 'B') {
            num_endA_and_beginB++;
            //cout << "BA: " + str << endl;
        }
    }

    if (num_endA_and_beginB != 0){
        ans += num_endA_and_beginB-1;
        if (num_endA>=1) {
            ans++;
            num_endA--;
        }
        if (num_beginB>=1) {
            ans++;
            num_beginB--;
        }

    }

    cout << ans + min(num_endA,num_beginB) << endl;

//    cout << ans << endl;
//    cout << "BA: " << num_endA_and_beginB << endl;
//    cout << " A: " << num_endA << endl;
//    cout <<"B : " <<  num_beginB << endl;


    return 0;
}

Measured memory_bytes: 768
n, l = map(int, input().split())

taste = []
mini = 10**9
suf = 0
for i in range(1,n+1):
    if abs(l+i-1) < mini:
        mini = abs(l+i-1)
        suf = i
    taste.append(l+i-1)

taste.pop(suf-1)
print(sum(taste))

Measured memory_bytes: 3060
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
*/

/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

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



int main(){
    
    int n;
    cin >> n;
    set<int> s;
    
    rep(i,0,n){
	int a;
	cin >> a;
	s.it(a);
    }
    
    if(n == sz(s))YES;
    else NO;
    return  0;
}


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

int main() {
  int s_1s_2s_3 , s_1 , s_2 , s_3;
  
  cin >> s_1s_2s_3;
  
  s_1 = s_1s_2s_3/100;
  s_2 = (s_1s_2s_3 - s_1*100)/10;
  s_3 = (s_1s_2s_3 - s_1*100 - s_2*10);
  
  cout << s_1 + s_2 + s_3 << endl;
}



Measured memory_bytes: 256
n2c = dict(zip(range(0,52),"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"))
c2n = dict(zip("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",range(0,52)))

def f(c,k):
	return n2c[(c2n[c]-k)%52]


while True:
	kl=int(raw_input())
	if kl==0: break
	ks = map(int, raw_input().split())
	oms = list(raw_input())
	nms = []
	for ki, om in enumerate(oms):
		k = ks[ki%kl]
		nm = f(om,k)
		nms.append(nm)
	print "".join(nms)

Measured memory_bytes: 4236
#define _GIBCXX_DEBUG
#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 namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void) {
  int D, G;
  cin >> D >> G;
  vector<int> p(D);
  vector<int> c(D);
  rep(i, D) {
    cin >> p[i] >> c[i];
  }

  ll ans = 1<<29;
  for (int bit = 0; bit < (1<<D); ++bit) {
    ll sum = 0;
    ll count = 0;
    rep(i, D) {
      if (bit & (1<<i)) {
        sum += c[i] + p[i] * 100 * (i+1);
        count += p[i];
      }
    }
    if (sum >= G) ans = min(ans, count);
    else {
      for (int i = D - 1; i >= 0; --i) {
        if (bit & (1<<i)) continue;
        for (int j = 0; j < p[i]; ++j) {
          if (sum >= G) break;
          sum += 100 * (i+1);
          ++count;
        }
      }
      ans = min(ans, count);
    }
  }

  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3604
# include <bits/stdc++.h>
# define pb push_back
# define ll long long
# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define DEBUG

using namespace std;

const ll N = 1e5 + 7;
const ll mod = 1e18 + 7;

int n, mx, mx2;

int main()
{
    speed;
    /// Author: Dilshod--Imomov
    #ifdef DEBUGn
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif // DEBUG
    cin >> n;
    vector < int > vc(n);
    for ( int i = 0; i < n; i++ ) {
        cin >> vc[i];
    }
    auto v = vc;
    sort(all(v));
    mx = v[n - 1];
    mx2 = v[n - 2];
    for ( auto x: vc ) {
        if ( x == mx ) {
            cout << mx2 << endl;
        }
        else {
            cout << mx << endl;
        }
    }
}


Measured memory_bytes: 3200
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iterator>
#include <cstdio>
#include <numeric>
using namespace std;
int main(){
  for(int tc = 1;; ++tc){
    int W;
    cin >> W;
    if(W == 0){
      break;
    }
    int n;
    cin >> n;
    int value[n], weight[n];
    for(int i = 0; i < n; ++i){
      scanf("%d,%d", &value[i], &weight[i]);
    }
    int table[n+1][W+1];    
    fill_n((int*)table, (n+1)*(W+1), 0);
    table[0][0] = 0; 
    for(int i = 0; i < n; ++i){
      for(int w = 0; w <= W; ++w){
	if(table[i][w] != -1){
	  table[i+1][w] = table[i][w];
	}
      }
      for(int w = weight[i]; w <= W; ++w){
	int tmp = w - weight[i];
	if(table[i][tmp] >= 0){
	  table[i+1][w] = max(table[i+1][w], table[i][tmp] + value[i]);
	}
      }    
    }
    int ans_w = 0, ans_v = 0;
    for(int w = 0; w <= W; ++w){
      if(ans_v < table[n][w]){
	ans_v = table[n][w];
	ans_w = w;
      }
    }
    cout << "Case " << tc << ":" << endl;
    cout << ans_v << endl;
    cout << ans_w << endl;
  }
  return 0;
}

Measured memory_bytes: 5164
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 1000000000;
const int mod = 1e9+7;
const int maxn = 2e5+5;
int main() {
	ll a,b;
	cin>>a>>b;
	if(b==1||a==1) cout<<1<<endl;
	else if(a%2==0){
		cout<<a*b/2<<endl;
	}
	else {
		cout<<(a/2)*b+(b+1)/2<<endl;
	}
    return 0;
}

Measured memory_bytes: 256
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_A&lang=jp
def bubble_sort(array):
    N = len(array)
    is_reversed_items_exist = True
    reverse_time = 0

    while  is_reversed_items_exist:
        is_reversed_items_exist = False
        for i in range(N - 1):
            if array[i] > array[i + 1]:
                array[i], array[i + 1] = array[i + 1], array[i]
                is_reversed_items_exist = True
                reverse_time += 1
    return reverse_time
    
def putsarray(array):
    for i in range(len(array) - 1):
        print(array[i], end=' ')
    print(array[-1])

if __name__ == "__main__":
    N = int(input())
    array = input().split()
    array = [int(n) for n in array]
    reverse_time = bubble_sort(array)
    putsarray(array)
    print(reverse_time)


Measured memory_bytes: 5608
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.stream.Stream;

public class Main {
    public static boolean solve(int[] a, int i, int m) {
        if(m == 0) {
            return true;
        }
        
        if(i >= a.length) {
            return false;
        }
        
        return solve(a, i + 1, m) || solve(a, i + 1, m - a[i]);
    }

    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int[] a = Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        int q = Integer.parseInt(br.readLine());
        int[] m = Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();

        for(int i = 0; i < q; i++) {
            if(solve(a, 0, m[i])) {
                System.out.println("yes");
            } else {
                System.out.println("no");
            }
        }
    }
}

Measured memory_bytes: 30992
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from collections import Counter

n, *v = map(int, read().split())
g = Counter(v[::2]).most_common()
k = Counter(v[1::2]).most_common()
if g[0][0] == k[0][0]:
    if len(g) > 1:
        if len(k) > 1:
            print(n - max(g[0][1] + k[1][1], g[1][1] + k[0][1]))
        else:
            print(n - g[1][1] - k[0][1])
    elif len(k) > 1:
        print(n - g[0][1] - k[1][1])
    else:
        print(n // 2)
else:
    print(n - g[0][1] - k[0][1])


Measured memory_bytes: 20636
#include <algorithm>
#include <climits>
#include <iostream>
#include <vector>

int main(int argc, char *argv[]) {
  std::vector<int> a;
  long n;
  std::cin >> n;
  while (n >= 1) {
    a.push_back(n % 10);
    n /= 10;
  }
  std::reverse(a.begin(), a.end());

  int min = INT_MAX;
  for (size_t i = 0; i < a.size() - 2; ++i) {
    int d = a.at(i) * 100 + a.at(i + 1) * 10 + a.at(i + 2);
    min = std::min(min, std::abs(753 - d));
  }
  std::cout << min << std::endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll             long long int
#define lb             lower_bound
#define ub             upper_bound
#define fi             first
#define mp             make_pair
#define vll            vector<ll>
#define se             second
#define mod            1000000007
#define endl            "\n"
#define fast           ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb             push_back
#define all(v)         v.begin(),v.end()
#define allr(v)        v.rbegin(),v.rend()
#define inp(V,n)       for(int i=0;i<n;i++){cin >> V[i];}
#define oup(V,n)       {for(int i=0;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
using namespace std;
ll factorial(ll n)
{
    return (n == 1 || n == 0) ? 1 : n * factorial(n - 1);
}
ll gcd(ll a, ll b)
{
    if (a == 0)
      return b;
    return gcd(b % a, a);
}
ll lcm(ll a, ll b)
{
   return (a*b)/gcd(a, b);
}
bool sortByVal(const pair<double,double> &a,
               const pair<double,double> &b)
{
    if(a.fi==b.fi)
    {
    return (a.second >b.second);
    }
    else
        return (a.fi<b.fi);
}


int main()
{
   ll t=1;
 // cin>>t;
   while(t--)
   { ll d,t,s;
   cin>>d>>t>>s;
     double dd =ceil(d*1.0/s);
     if(dd<=t)
        cout<<"Yes"<<endl;
     else cout<<"No"<<endl;



   }
   return 0;
}


Measured memory_bytes: 3628
N,M=map(int, input().split())
G=[[] for _ in range(N)]
H=[]
import sys
sys.setrecursionlimit(10**6)
for i in range(M):
    a,b=map(int, input().split())
    G[a-1].append((b-1,i))
    G[b-1].append((a-1,i))
    H.append((i,a-1,b-1))
def dfs(start, goal, banned):
    done[start]=1
    if start==goal:
        ok[0]=True
    for t in G[start]:
        nex, num=t
        if num==banned:
            continue
        elif done[nex]==-1:
            dfs(nex, goal, banned)
    
ans=M
for h in H:
    i,a,b=h
    done=[-1]*N
    ok=[False]
    dfs(a,b,i)
    if ok[0]:
        ans-=1
print(ans)

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unrolled-loops")
#define int long long
#define y1 hoainambimaysolokill
#define fi first
#define se second
#define PII pair<int,int>
#define PII2 pair<int,pair<int,int> >
#define PII3 pair<pair<int,int>,int >
const long long inf=1e18+3;
int ans,res,n,a[100010];
void solve()
{
   cin>>n;
   for(int i=0;i<n;i++)cin>>a[i];
   for(int i=1;i<n;i++){
       if(a[i]<=a[i-1])ans=max(ans,++res);
       else res=0;
   }
   cout<<ans;
}
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);

    //freopen("BOXES.inp", "r", stdin);
    //freopen("BOXES.out", "w", stdout);

    //int t;cin>>t;while(t--)

    solve();
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < int(n); ++ (i))
using namespace std;
template <class T> inline void chmax(T & a, T const & b) { a = max(a, b); }

bool pred(string const & t) {
    int n = t.length();
    if (n % 2 == 0) return false;
    if (n < 3) return false;
    if (t[n / 2 - 1] != 'i') return false;
    if (t[n / 2    ] != 'w') return false;
    if (t[n / 2 + 1] != 'i') return false;
    REP (i, n / 2 - 1) {
        char c;
        switch (t[i]) {
            case '(': c = ')'; break;
            case ')': c = '('; break;
            case '[': c = ']'; break;
            case ']': c = '['; break;
            case '{': c = '}'; break;
            case '}': c = '{'; break;
            default: return false;
        }
        if (c != t[n - i - 1]) return false;
    }
    return true;
}

int main() {
    string s; cin >> s;
    int result = 0;
    REP (x, 1 << s.length()) {
        string t;
        REP (i, s.length()) if (x & (1 << i)) {
            t += s[i];
        }
        if (pred(t)) {
            chmax<int>(result, t.length());
        }
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

char dif = 'A' - 'a';

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    ll sum = 0;
    for (ll i = k + 1; i <= n;i++){
        ll p = n / i;
        sum += p * max((ll)0, i - k);
        sum += max((ll)0, n % i - k + 1);
    }
    if(k==0)
        cout << n * n << endl;
        else
            cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
const long long INFll = (1ull<<62) - 1;

struct Edge
{
	int to;
	long long capacity;
};

struct Dinic
{
	struct Edge_Res
	{
		int to;
		long long capacity;
		int reverse_idx;
		bool is_backword;
	};

	int V;
	vector<vector<Edge_Res>> resnet;
	int s, t;
	long long max_flow;
	vector<int> level;
	vector<int> iter;

	Dinic(const vector<vector<Edge>> &g) : V(g.size()), resnet(V) {
		for (int i = 0; i < V; i++) {
			for (const Edge &e : g[i]) {
				resnet[i].push_back(Edge_Res{e.to, e.capacity, (int)resnet[e.to].size(), false});
				resnet[e.to].push_back(Edge_Res{i, 0, (int)resnet[i].size()-1, true});
			}
		}
	}

	Dinic(int V) : V(V), resnet(V) {}

	void add_edge(int from, int to, long long capacity) {
		resnet[from].push_back(Edge_Res{to, capacity, (int)resnet[to].size(), false});
		resnet[to].push_back(Edge_Res{from, 0, (int)resnet[from].size()-1, true});
	}

	bool is_s(int v) {
		return level[v] >= 0;
	}

	void calc(int s, int t) {
		this->s = s;
		this->t = t;
		max_flow = 0;
		while (true) {
			bfs(s);
			if (level[t] == -1) break;
			iter.assign(V, 0);
			while (true) {
				long long f = dfs(s, INFll);
				if (f > 0) max_flow += f;
				else break;
			}
		}
		iter.clear();
		iter.shrink_to_fit();
	}

	void bfs(int s) {
		level.assign(V, -1);
		queue<int> q;
		q.push(s);
		level[s] = 0;
		while (!q.empty()) {
			int v = q.front(); q.pop();
			for (Edge_Res &e : resnet[v]) {
				if (e.capacity <= 0) continue;
				if (level[e.to] != -1) continue;
				level[e.to] = level[v] + 1;
				q.push(e.to);
			}
		}
	}

	long long dfs(int v, long long flow) {
		if (v == t) return flow;
		for (int &i = iter[v]; i < resnet[v].size(); i++) {
			Edge_Res &e = resnet[v][i];
			if (e.capacity <= 0) continue;
			if (level[e.to] <= level[v]) continue;
			long long f = dfs(e.to, min(flow, e.capacity));
			if (f == 0) continue;
			e.capacity -= f;
			resnet[e.to][e.reverse_idx].capacity += f;
			return f;
		}
		return 0;
	}
};

int main() {
	int n;
	cin >> n;
	vector<long long> a(n+1);
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	long long ans = 0;
	Dinic D(n+2);
	for (int i = 1; i <= n; i++) {
		if (a[i] > 0) {
			ans += a[i];
			D.add_edge(i, n+1, a[i]);
		} else {
			D.add_edge(0, i, -a[i]);
		}
		for (int j = 2*i; j <= n; j += i) {
			D.add_edge(i, j, INFll);
		}
	}
	D.calc(0, n+1);
	ans -= D.max_flow;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3212
#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 reps(i, s, e) for(int i=s; i<e; i++)
#define inf 1e18
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*b/gcd(a, b); }
template<typename T> T vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> T adebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    ll n, tmp;
    vector<ll> x;
    cin >> n;
    rep(i, n){
        cin >> tmp;
        x.push_back(tmp);
    }

    vector<ll> buf = x;

    sort(x.begin(), x.end());

    ll cl = x[n/2-1];
    ll cr = x[n/2];

    rep(i, n){
        if(cr == cl){
            cout << cl << endl;
        }else{
            if(buf[i] <= cl){
                cout << cr << endl;
            }
            if(buf[i] >= cr){
                cout << cl << endl;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 5488
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stdlib.h>
#include <cmath>
#include <math.h>
#include <fstream>
#include <bitset>
#include <time.h>
#include <queue>
#define int long long
using namespace std;
int n, m, ai, bi;
set<int> f, l;
int32_t main(){
    cin >> n >> m;
    for (int i=0; i < m; i++){
        cin >> ai >> bi;
        if (ai == 1){
            f.insert(bi);
            if (l.count(bi)){
                cout << "POSSIBLE" << endl;
                return 0;
            }
        }
        if (bi == 1){
            f.insert(ai);
            if (l.count(ai)){
                cout << "POSSIBLE" << endl;
                return 0;
            }
        }
        if (ai == n){
            l.insert(bi);
            if (f.count(bi)){
                cout << "POSSIBLE" << endl;
                return 0;
            }
        }
        if (bi == n){
            l.insert(ai);
            if (f.count(ai)){
                cout << "POSSIBLE" << endl;
                return 0;
            }
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}


Measured memory_bytes: 9600
import math
a,b,x = map(int, input().split())

x_bound = a*a*b/2

if x<=x_bound:
    y = 2*x/(a*b)
    print(math.degrees(math.atan(b/y)))
else:
    z = 2*x/(a*a) - b
    print(math.degrees(math.atan((b-z)/a)))


Measured memory_bytes: 3060
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	a := intScanner()
	fmt.Println(a + a*a + a*a*a)
}


Measured memory_bytes: 1772
#include <bits/stdc++.h>
#define ll long long int
#define F first
#define S second
#define pub push_back
#define pob pop_back
#define M 1000000007
#define pii pair<ll,ll>
#define mp make_pair
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    ll n,m,c,i,a[100],b[100],s,ans=0;
    cin>>n>>m>>c;
    for(i=0;i<m;i++)cin>>b[i];
    while(n--)
    {
    	for(i=0;i<m;i++)cin>>a[i];

    	s=0;
    	for(i=0;i<m;i++)
    	{
    		s+=a[i]*b[i];
    	}
    	s+=c;
    	if(s>0)ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
import numpy as np
i8 = np.int64


def solve(a):
    x = 1
    res = 0
    for i in range(a.shape[0]):
        if a[i] == x:
            x += 1
        else:
            res += 1
    return res


def main():
    stdin = open('/dev/stdin', 'rb')
    pin = np.fromstring(stdin.read(), i8, sep=' ')
    n = pin[0]
    a = pin[1:]
    ans = solve(a)
    if ans == n:
        print(-1)
    else:
        print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 15556
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

main() {
    int64_t n;
    cin >> n;

    constexpr auto K = 3;
    vector<array<int64_t, K>> v(n);
    for (auto&& vv : v) {
        for (auto&& vvv : vv) {
            cin >> vvv;
        }
    }

    array<int64_t, K> value{};
    for (const auto& vv : v) {
        decltype(value) next{};
        for (auto i : irange(0, K)) {
            for (auto j : irange(0, K)) {
                if (i != j) {
                    next[i] = max(next[i], value[j]);
                }
            }
            next[i] += vv[i];
        }

        value = move(next);
    }

    cout << *max_element(value.begin(), value.end()) << endl;
}

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

int main() {
	long long n, m; cin >> n >> m; 
	if (n > m)swap(n, m);
	if (n == 1 && m == 1)cout << 1 << endl;
	else if (n == 1 && m != 1)cout << m - 2 << endl;
	else cout << (long long)(n - 2) * (m - 2) << endl;

	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define all(obj) (obj).begin(), (obj).end()
#define lpair pair<ll, ll>
#define vint vector<ll>
#define vinput(name) for(int i=0; i<(int)(name.size()); i++) cin >> name[i];
#define voutput(name) for(int i=0; i<(int)(name.size()); i++) cout << name[i] << endl;
typedef long long ll;

using namespace std;

// auto mod int
const int mod = 1000000007;
struct mint {
	ll val; // typedef long long ll;
	mint(ll x=0):val((x% mod+mod)%mod){}
	mint operator-() const { return mint(-val); }
	mint& operator+=(const mint a) {
		if((val += a.val) >= mod) val -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if((val += mod-a.val) >= mod) val -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(val *= a.val) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res*=a;
	}
	//2^n
	mint pow(ll n) const {
		if(!n) return 1;
		mint a = pow(n>>1);
		a *= a;
		if(n&1) a *= *this;
		return a;
	}
	//x^n
	mint mod_pow(ll x, ll n){
		if(n == 0) return 1;
		mint res = mod_pow(x*x % MOD, n/2);
		if(n & 1) res = res.val * x % MOD;
		return res;
	}
	mint choose(ll n, ll a){
		mint x = 1, y = 1;
		rep(i, a){
			x *= n-i;
			y *= i+1;
		}
		return x / y;
	}

	// for prime mod
	mint inv() const {
		return pow(mod-2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res/=a;
	}
};

mint ans = 0;

ll mod_pow(ll x, ll n){
	if(n == 0) return 1;
	ll res = mod_pow(x*x % MOD, n/2);
	if(n & 1) res = res * x % MOD;
	return res;
}

int main(void){
	ll n, a, b; cin >> n >> a >> b;

	ans = ans.mod_pow(2, n);
	ans -= 1;
	ans -= ans.choose(n, a);
	ans -= ans.choose(n, b);
	cout << ans.val << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int S = sc.nextInt();
      int h = S / 3600;
      int m = (S % 3600) / 60;
      int s = S % 60;
      System.out.println(h + ":" + m + ":" + s);
   } 
}

Measured memory_bytes: 17352
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

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

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) do{sort(v.begin(), v.end()); v.erase( unique(v.begin(), v.end()), v.end() );} while(0)

#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

int a, b, c, d, e, f;

int main(){
  cin >> a >> b >> c >> d >> e >> f;

  vi water, sugar;
  REP(i, 31) REP(j, 31) {
    if(i * a + j * b <= 30) water.pb(i * a + j * b);
  }
  REP(i, 1501) REP(j, 1501) {
    if(i * c + j * d <= 1500) sugar.pb(i * c + j * d);
  }

  UNIQUE(water);
  UNIQUE(sugar);

  double m = 0.0;
  int ms = 0, mw = a;
  REP(i, water.size()) {
    REP(j, sugar.size()) {
      int w = water[i], s = sugar[j];
      if(w * 100 + s <= f && w * e >= s) {
        if(m < double(s)/double(s + w * 100)) {
          m = double(s)/double(s + w * 100);
          ms = s;
          mw = w;
        }
      }
    }
  }

  cout << ms + mw * 100 << " " << ms << endl;

  return 0;
}


Measured memory_bytes: 5492
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>

int main() {
    std::vector<double> v;
    double elevation;

    while (std::cin >> elevation) {
        v.push_back(elevation);
    }

    std::cout << std::fixed << std::setprecision(2)
              << *std::max_element(v.begin(), v.end())
                - *std::min_element(v.begin(), v.end())
              << std::endl;

    return 0;
}

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

void ok(){
	cout << "Yes" << endl;
	exit(0);
}

void ng(){
	cout <<  "No" << endl;
	exit(0);
}

int p[324000], n;

int main(){
	cin >> n;
	for(int i  = 0;i < n;i++){
		cin >> p[i];
		if(i % 2 == p[i] % 2)ng();
	}

	for(int k = 0;k < 100;k++){
		for(int i = n-3;i >= 0;i--){
			int a = p[i], b = p[i+1], c = p[i+2];
			if(a > b && b > c){
				swap(p[i], p[i+2]);
			}
		}
	}
		for(int i = 1;i < n-1;i++){
		int a = p[i-1], b = p[i], c = p[i+1];
		if((a > c) && (a < b || b < c))ng();
	}
	ok();
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  int l = 0, r = 1e6;
  cin >> n >> m;
  while(m--) {
    int t, s;
    cin >> t >> s;
    if(t > l) l = t;
    if(s < r) r = s;
  }
  cout << max(0, (r-l+1)) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;
const ll inf = 1e18+5;
ll n, dp[(1 << 21)+5], grid[25][25];
const ll mod = 1e9+7;
ll add(ll a, ll b){
	return (a%mod +b%mod+mod)%mod;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> n;
	for (ll i = 0; i < n; i++){
		for (ll j = 0; j < n; j++)cin >> grid[i][j];
	}
	dp[0] = 1;
	//dp[mask] stores the women matched
	for (ll i = 0; i <= (1 << n)-1; i++){
		ll a = __builtin_popcountll(i);
		//a is the no. of men matched == no. of women matched
		for (ll j = 0; j < n; j++){
			if (grid[a][j] && !(i &(1 << j))){
				//if i can match the current man and the women(indicated by a nonset bit)
				//i increment the new 
				ll nmask = i | (1 << j);
				dp[nmask] = add(dp[nmask], dp[i]);
			}
		}
	}
	cout << dp[(1 << n)-1];
}


Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

vp prime_factorize(int n){
    vp ret;
    for(int p=2; p*p<=n; p++){
        if(n%p!=0) continue;
        int num=0;
        while(n%p==0){
            num++;
            n/=p;
        }
        ret.PB(MP(p,num));
    }
    if(n!=1) ret.PB(MP(n,1));
    return ret;
}

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

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

    int n,m; cin >> n >> m;
    vp pf=prime_factorize(m);
    int res=1;
    for(auto p:pf){
        int num=p.S;
        for(int i=1; i<=num+n-1; i++) {
            res*=i; res%=MOD;
        }
        for(int i=1; i<=num; i++){
            res*=modpow(i,MOD-2,MOD);
            res%=MOD;
        }
        for(int i=1; i<=n-1; i++){
            res*=modpow(i,MOD-2,MOD);
            res%=MOD;
        }
    }
    cout<<res<<endl;
       
}

Measured memory_bytes: 3656
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy

def main():
    num = list(map(int, input().split()))
    num.sort(reverse=True)
    print(num[0]*10+num[1] + num[2])

if __name__ == "__main__":
    main()


Measured memory_bytes: 9616
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int N;
ll D;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N >> D;
    int ans = 0;
    for(int i = 0; i < N; i++){
        ll x, y;
        cin >> x >> y;
        ll s = x*x+y*y;
        if(s <= D*D) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3648
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")


def input():
    return sys.stdin.readline().strip()


def INT():
    return int(input())


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


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


def ZIP(n):
    return zip(*(MAP() for _ in range(n)))


def main():
    a = INT()
    print(a+a**2+a**3)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9172
#include <algorithm>
#include <bitset>
#include <complex>
#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>
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

int main() {
	int N, R;
	int real;

	cin >> N >> R;

	if (N < 10) {
		real = R + 100 * (10 - N);
	}
	else {
		real = R;
	}

	cout << real << endl;

}

Measured memory_bytes: 256
def e_sum_of_gcd_of_tuples_hard(MOD=10**9 + 7):
    N, K = [int(i) for i in input().split()]
    ans = [0] * (K + 1)
    for i in range(K, 0, -1):
        multiple = K // i
        ans[i] = pow(multiple, N, MOD)
        # i の値を K から小さくしていかないと、この処理が誤りとなる
        for j in range(2 * i, K + 1, i):
            ans[i] -= ans[j]  # i の倍数 (2倍以上) の分を引く
        ans[i] %= MOD
    return sum([i * ans[i] for i in range(K + 1)]) % MOD

print(e_sum_of_gcd_of_tuples_hard())

Measured memory_bytes: 15156
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>

using namespace std;

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

const int mod=1e9+7;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    int cnt=0;
    for(int i=0;i<n-1;i++){
        if(a[i]==a[i+1]){
            cnt++;
        }
    }
    a.erase(unique(a.begin(),a.end()),a.end());
    cout << (cnt%2==0?a.size():a.size()-1) << endl;
}

Measured memory_bytes: 640
//21171_somesh || asomesh999

#include<bits/stdc++.h>
using namespace std;
#define fr(i,a,b) for(long long i=a;i<b;i++)
#define io ios::sync_with_stdio(false);cin.tie(NULL);
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
long int mod=13;

int n;
vector<vl> dp;
string s;

ll rec(ll pos, ll rem) {
	if(pos == n) {
		return (rem == 5);
	}
	if(dp[pos][rem] != -1) {
		return dp[pos][rem];
	}
	ll ans = 0;
	if(s[pos] != '?') {
		ll ele = s[pos] - '0';
		ele = (rem * 10 + ele) % mod;
		ans = rec(pos + 1, (ele) % mod);
	}
	else {
		fr(i, 0, 10) {
			ll ele = rem * 10 + i;
			ele %= mod;
			ans = (ans + rec(pos + 1, (ele) % mod)) % 1000000007;
		}
	}
	return dp[pos][rem] = ans % 1000000007;
}

int main()
{
	io
	#ifdef SOMU
		clock_t startTime = clock();
		freopen("input.txt","r",stdin);
	#endif

	cin >> s;
	n = s.size();
	dp.resize(n, vl(13, -1));
	cout << rec(0, 0);

	#ifdef SOMU
		cerr << endl <<setprecision(20)<< double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " seconds." << endl;
	#endif
	return 0;
}

Measured memory_bytes: 21456
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <string>
#include <algorithm>
#include <string>
#include <climits>
#include <utility>

#define REP(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define REG(i, a, b) for (int (i) = ((int)(a)); (i) < ((int)(b)); i++)
#define ALL(V) (V).begin(), (V).end()
#define PRINT(STR) cout << (STR) << endl
#define ROUNDED(N) fixed << setprecision(N)
#define SPACE " "

typedef long long ll;
using namespace std;

int nextInt() { int n; cin >> n; return n; }
double nextDouble() { double d; cin >> d; return d; }
string nextString() { string str; cin >> str; return str; }

int main() {
	cin.tie(0); //対話型には使えない
	ios::sync_with_stdio(false); //printfと共には使えない
	int n;
	cin >> n;
	vector<int> t(n),a(n);
	REP(i,n) cin >> t[i] >> a[i];
	long long minT = 1,minA = 1;
	for(int i = 0; i < n; i++){
		long long propotion = max((minT-1)/t[i] + 1, (minA-1)/a[i] + 1);
		minT = propotion * t[i];
		minA = propotion * a[i];
	}
	cout << minT + minA << endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;

int main()
{
    long long int n, m;
    cin >> n >> m;

    vector<pair<long long int,long long int>> ab(n);
    for (int i = 0; i < n; i++)
        cin >> ab[i].first >> ab[i].second;

    sort(ab.begin(), ab.end());

    long long int count = 0;
    long long int ans = 0;
    for (int i = 0; i < n;i++)
    {
        if (ab[i].second > m)
        {
            ans += m * ab[i].first;
            break;
        }
        else
        {
            ans += ab[i].second * ab[i].first;
            m -= ab[i].second;
        }
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;
using Graph = vector<vector<int>>;
using Grid= vector<vector<char>>;
using vin= vector<int>;
using ll=long long;
using vll= vector<ll>;
using vbl=vector<bool>;
using vch=vector<char>;
using pinin=pair<int ,int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rell(i,n) for (ll i=0; i< (ll)(n); i++)
#define sort(x) sort(x.begin(), x.end());
#define rese(x) reverse(x.begin(), x.end());
#define vnn(x,y,name) vector<vector<int>> name(x, vector<int>(y));

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

int main() {
    int n,m,x;
    cin>>n>>m>>x;
    vin c(n);
    vnn(n,m,a);
    rep(i,n){
        cin>>c[i];
        rep(j,m){
            cin>>a[i][j];
        }
    }
    bool ok=false;
    int ans=1001001001;
    rep(i,4096){
        bitset<12> hant(i);
        vin cnt(m,0);
        int ansa=0;
        rep(j,n){
            if(hant[j]){
                rep(k,m){
                    cnt[k]+=a[j][k];
                }
                ansa+=c[j];
            }
        }
        bool allok=true;
        rep(j,m){
            if(cnt[j]<x) allok=false;
        }
        if(allok){
            ok=true;
            ans=min(ans,ansa);
        }
        
    }
    if(ok) cout<<ans<<endl;
    else cout<<-1<<endl;
  

}


Measured memory_bytes: 3620
N, M = map(int, input().split())
if N == 1 and M == 1:
    print(1)
elif N == 1 and M >= 2:
    print(M - 2)
elif N >= 2 and M == 1:
    print(N - 2)
else:
    print((M-2) * (N-2))

Measured memory_bytes: 9176
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	int x; cin >> x;
	for (long long i = -5000; i <= 5000; ++i) {
		for (long long j = -5000; j <= max(0LL, i); ++j) {
			if (i * i * i * i * i - j * j * j * j * j == x) {
				cout << i << " " << j << endl;
				return 0;
			}
		}
	}

	return 0;
}

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

int main()
{
    int x,a;
    cin >> x >> a;
    cout << (x<a ? 0 : 10) << endl;
    return 0;
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  bool pos[107];
  pos[0] = 1;
  for(int i=1; i<=100; i++) pos[i] = false;
  for(int i=4; i<=100; i++) {
    if(pos[i-4]) pos[i] = true;
  }
  for(int i=7; i<=100; i++) {
    if(pos[i-7]) pos[i] = true;
  }
  puts(pos[n] ? "Yes" : "No");
}


Measured memory_bytes: 256