akhauriyash/Code-Regression huggingface dataset:
use std::cmp::{max, min};

const MOD: i64 = 1000000007;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn factorial_mod(n: i64, m: i64) -> i64{
    if n == 1{
        1 as i64
    }else{
        (factorial_mod(n-1, m) % m * n) % m
    }
}

fn main() {
    input! {
        n: i64,
        m: i64,
    }
    if n == m{
        // 2 * n! * n!
        println!("{}", (factorial_mod(n, MOD) * factorial_mod(n, MOD) * 2) % MOD);
    }else if n == m+1 || n == m - 1{
        // n! * m! = (min(n,m)!)^2 * max(n,m)
        println!("{}", (factorial_mod(min(n, m), MOD) * factorial_mod(min(n,m), MOD) % MOD * max(n,m)) % MOD);
    }else{
        println!("{}", 0);
    }

}

Measured memory_bytes: 5884
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int n;
    cin >> n;
    cout << "ABC" << n << endl;
}

Measured memory_bytes: 384
Number_of_Data=int(input().rstrip())
Judge_Result = [input().split() for i in range(int(Number_of_Data))]
Result_counter=[[0],[0],[0],[0]]#AC,WA,TLE,RE
for i in range(Number_of_Data):
    if Judge_Result[i][0]=='AC':
        Result_counter[0][0] +=1
    elif Judge_Result[i][0]=='WA':
        Result_counter[1][0] +=1
    elif Judge_Result[i][0]=='TLE':
        Result_counter[2][0] +=1
    elif Judge_Result[i][0]=='RE':
        Result_counter[3][0] +=1

print("AC x {}".format(Result_counter[0][0]))
print("WA x {}".format(Result_counter[1][0]))
print("TLE x {}".format(Result_counter[2][0]))
print("RE x {}".format(Result_counter[3][0]))


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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

using ll = long long;
using ull = unsigned long long;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    long double r;cin >> r;
    cout << fixed << setprecision(10);
    cout << 2*r*3.1415926535 << endl;
    return 0;
}


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

int main()
{
  int N, a = 0;
  cin >> N;

  int n = N;

  while (n > 0) {
    a += n % 10;
    n /= 10;
  }

  if (N % a == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
    int N;
    int i;
    long sum = 0;
    
    scanf("%d", &N);
    
    for (i = 1; i <= N; i ++) {
        if (i % 3 != 0 && i % 5 != 0) {
            sum += i;
        }
    }

    printf("%ld\n", sum);
    
    return 0;
}

Measured memory_bytes: 1728
import itertools


def main():
    num = int(input())
    array = [int(x) for x in input().split()]
    array.sort()
    ans = 0
    for ls in itertools.combinations(array, 3):
        if ls[0] != ls[1] and ls[1] != ls[2]:
            if ls[0] + ls[1] > ls[2]:
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9180
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
int b[200];
int main() {
    b[0]=1000000;
    scanf("%d",&n);
    b[n]=1000000;
    int res=0;
    for(int i=1;i<n;i++)
        scanf("%d",&b[i]);
    for(int i=1;i<=n;i++)
        res += min(b[i-1],b[i]);
    printf("%d\n",res);
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  int n, m;
  vector<pair<int,int> > vec[SIZE];
  char ans[SIZE][13];
  
  scanf("%d%d", &n, &m);

  for(int i=0;i<m;i++){
    int p, y;
    scanf("%d%d", &p, &y);
    vec[p].push_back({y, i});
  }

  for(int i=0;i<=n;i++){
    sort(vec[i].begin(), vec[i].end());

    for(int j=0;j<vec[i].size();j++){
      sprintf(ans[vec[i][j].second], "%06d%06d", i, j+1);
    }
  }

  for(int i=0;i<m;i++){
    printf("%s\n", ans[i]);
  }
  
  return 0;
}



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

int n,tmp,now,nownum;
int a[100010];

inline int get_num()
{
	int now=0,fh=1;char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-')fh=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		now=(now<<1)+(now<<3)+ch-'0';
		ch=getchar();
	}
	return now*fh;
}

int main()
{
	n=get_num();
	for(int i=1;i<=n;i++){
		tmp=get_num();
		a[tmp]++;
		a[tmp-1]++;
		a[tmp+1]++;
	}
	for(int i=1;i<=100000;i++){
		nownum=max(nownum,a[i]);
	}
	printf("%d\n",nownum);
	return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vi b(n-1);
    rep(i, n-1) cin >> b[i];
    vi a(n);
    a[0] = b[0];
    a[n-1] = b[n-2];
    for (int i=1; i<=n-2; ++i) a[i] = min(b[i-1], b[i]);
    int ans = 0;
    rep(i, n) ans += a[i];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm> // sort
#include <map>       // pair
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i, j, n) for (int i = j; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;

int main()
{
    int n;
    cin >> n;
    map<ll,int> mp;
    vector<long> p;
    rep(i, n)
    {
        ll a;
        cin>>a;
        a--;
        if(mp[a]==1)
            mp[a]=0;
        else
        {
            mp[a]=1;
        }
        
        p.push_back(a);

    }
    int ans = 0;
    for (auto elm : mp) {
        if(elm.second %2 ==1)
            ans++;
    }   
    cout << ans << endl;
}

Measured memory_bytes: 7284
package main

import (
	"fmt"
	"sort"
)

type Poll struct {
	name  string
	value int
}

type List []Poll

func (l List) Len() int {
	return len(l)
}

func (l List) Swap(i, j int) {
	l[i], l[j] = l[j], l[i]
}
func (l List) Less(i, j int) bool {
	if l[i].value == l[j].value {
		return (l[i].name < l[j].name)
	}
	return (l[i].value > l[j].value)
}

func main() {
	var n int
	fmt.Scan(&n)

	list := make([]string, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&list[i])
	}
	m := map[string]int{}
	for i := 0; i < n; i++ {
		m[list[i]]++
	}

	a := List{}
	for k, v := range m {
		e := Poll{k, v}
		a = append(a, e)
	}
	sort.Sort(a)
	fmt.Println(a[0].name)
	for i := 1; i < len(a); i++ {
		if a[i].value == a[i-1].value {
			fmt.Println(a[i].name)
		} else {
			break
		}
	}

}


Measured memory_bytes: 45772
#include<bits/stdc++.h>
using ll = long long;
const ll INF = 1000000000000;

int main()
{
    std::string s;
    std::cin >> s;
    if(s[5] == '0' && s[6] <= '4')std::cout << "Heisei" << std::endl;
    else std::cout << "TBD" << std::endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)

string s;

bool isValid(vector<int> ans,int n){
	rep(i,n){
		if(ans[i]==0){
			if(s[i]=='o'){
				if( ans[(i-1+n)%n]!=ans[(i+1)%n] )return false;
			}else{
				if( ans[(i-1+n)%n]==ans[(i+1)%n] )return false;
			}
		}else{
			if(s[i]=='o'){
				if( ans[(i-1+n)%n]==ans[(i+1)%n] )return false;
			}else{
				if( ans[(i-1+n)%n]!=ans[(i+1)%n] )return false;
			}
		}
	}
	return true;
}

bool solve(vector<int> &ans){
	int n = ans.size();
	for(int i=1;i<ans.size()-1;i++){
		if(ans[i]==0){
			if(s[i]=='o')	ans[(i+1)%n] = ans[i-1];
			else			ans[(i+1)%n] = !ans[i-1];
		}else{
			if(s[i]=='o')	ans[(i+1)%n] = !ans[i-1];
			else			ans[(i+1)%n] = ans[i-1];
		}
	}
	return isValid(ans,n);
}

int main(){
	int n;
	cin>>n;
	cin>>s;
	
	rep(i,2){
		rep(j,2){
			vector<int> ans(n,0);
			ans[0]=i;
			ans[1]=j;
			if( solve(ans) ){
				rep(k,ans.size()){
					if(ans[k]==1)cout<<"W";
					else cout<<"S";
				}
				cout<<endl;
				return 0;
			}
		}
	}
	cout<<-1<<endl;
}

Measured memory_bytes: 1376
n,m=map(int,input().split())
A=sorted(list(map(int,input().split())),reverse=True)
L=[0,2,5,5,4,5,6,3,7,6]

inf=float('inf')
#dp[i]=i本で最大何桁作れるか
dp=[-inf]*(n+1)
dp[0]=0
for i in range(1,n+1):
    for j in range(m):
        num=L[A[j]]
        if i>=num:
            dp[i]=max(dp[i],dp[i-num]+1)

sort_A=sorted(A,reverse=True)
ans=''
while True:
    if n==0:
        break
    for i in range(m):
        temp=sort_A[i]
        num=L[temp]
        if n>=num and dp[n-num]>=0:
            if dp[n-num]==dp[n]-1:
                ans+=str(temp)
                n-=num
                break
    

print(int(ans))





Measured memory_bytes: 9312
#include <stdio.h>
#include <stdlib.h>

int main() {
  long long int n,k,a,b,counter,bmin;
  scanf("%lld %lld",&n,&k);
  for(b=k+1;b<n+1;b++) {
    if(n%b>k-1) {
      if(k==0) {
        counter += (n/b)*(b-k)+(n%b-k+1)-1;
      } else {
        counter += (n/b)*(b-k)+(n%b-k+1);
      }
    } else {
        counter += (n/b)*(b-k);
    }
  }
  printf("%lld\n",counter);
  return 0;
}


Measured memory_bytes: 256
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end
x, y = gets_i_list

0.upto(x) do |a|
  b = x - a
  if (2 * a + 4 * b) == y
    puts "Yes"
    exit
  end
end

puts "No"

Measured memory_bytes: 14668
#include <cstdio>

using namespace std;

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i) {
    int x;
    scanf("%d", &x);
    n -= x;
  }
  if (n < 0) {
    n = -1;
  }
  printf("%d\n", n);
}


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

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

    auto a = vector<int>(N);
    for (auto& x : a) cin >> x;

    auto b = vector<int>(N);
    for (auto i = 0; i < N; i++)
        b[i] = max(a[i], 0);

    using ll = long long;
    auto asum = vector<ll>(N+1), bsum = vector<ll>(N+1);
    for (auto i = 1; i <= N; i++)
    {
        asum[i] = asum[i-1] + a[i-1];
        bsum[i] = bsum[i-1] + b[i-1];
    }

    auto result = 0LL;
    for (auto i = K; i <= N; i++)
    {
        const auto window = max(asum[i]-asum[i-K], 0LL);
        const auto other = bsum[N] - (bsum[i] - bsum[i-K]);
        result = max(result, window + other);
    }

    cout << result << endl;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
int n;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=3500;i++)
		for(int j=1;j<=3500;j++)
		{
			long long x=(long long)n*i*j;
			long long y=(long long)i*j*4-(long long)n*j-(long long)n*i;
			if(y<=0) continue;
			if(x%y==0)
			{
				printf("%d %d %lld",i,j,x/y);
				exit(0);
			}
		}
	return 0;
}

Measured memory_bytes: 256
#include <cstring>
#include <iostream>
#include <string>
#include <cstdio>

using namespace std;

int main()
{
    string s;
    cin>>s;
    if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I')
        printf("Yes\n");
    else
        printf("No\n");
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include<string>
#include<math.h>
#include <functional>
using namespace std;

int main(void) {
	int N;
	long int ans = 0;
	cin>>N;
	for (long int i = 0;i < N;i++) {
		long int a;
		cin >> a;
		for (; a % 2 != 1;a /= 2)
			ans++;
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int dp[10000] = { 0 };


int main() {
	int v[100];
	int w[100];
	int N;
	int W;

	cin >> N >> W;

	for (int i = 0; i < N; i++) {
		cin >> v[i] >> w[i];
	}

	for (int i = 0; i < N; i++) {
		for (int j = W; j >= 0;j--) {
			if (dp[j] != 0) {
				if (j + w[i] <= W) {
					dp[j + w[i]] = max(dp[j + w[i]], dp[j] + v[i]);
				}
			}
		}
		dp[w[i]] = max(dp[w[i]],v[i]);
	}

	int temp = 0;
	for (int i = 0; i <= W; i++) {
		temp = max(dp[i], temp);
	}
	cout << temp << endl;
	return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string> //文字列
#include <iomanip> //doubleの桁数指定 setprecision()
#include <list> //前後に数値を入れれる配列
#include <map> //map
#include <vector> //vecror

#define REP(i,m,n) for(ll i = (ll) (m);i < (ll) (n);i++) //forの短縮
#define rep(i,n) REP(i,0,n) //REPが0の時
#define ll long long int

using namespace std;

double PI = acos(-1); //円周率
ll mod = 1e9 + 7;


//提出コード
string s, t;
bool J = true;

int main() {

	cin >> s >> t;
	rep(i, s.size()) {
		if (s[i] != t[i]) J = false;
	}
	if (J) cout << "Yes" << endl;
	else cout << "No" << endl;
	




	return 0;
}



Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define SIZE 100
#define rep(i, N) for (i = 0; i < N; i++) //制御変数iを用いてN回転
#define array(N, t) ((t)*)calloc(N, sizeof(t)) //t型N要素の配列を動的確保後0クリア(freeを忘れずに)
#define zero(a); {int iter; rep(iter, sizeof(a)/sizeof((a)[0])) (a)[iter]=0;} //1次元配列aのゼロ初期化?
typedef long long ll;
void printa_int(int *a, int size); //int型の1次元配列aを出力(for debug)

int main() {
    char S[11];
    char T[12];
    scanf("%s\n%s", S, T);
    if (!strncmp(S, T, strlen(S))) printf("Yes\n");
    else printf("No\n");
    return 0;
}

void printa_int(int *a, int size) {
    int i;
    for (i = 0; i < size; i++)
        printf("%d, ", a[i]);
    printf("\n");
}

Measured memory_bytes: 1708
#include <bits/stdc++.h>
using namespace std;
int main()
{
	 int n,W;
    cin>>n>>W;
    long long w[n];
    long long v[n];
    for(int i=0;i<n;i++) cin>>w[i]>>v[i];
    long long dp[100005];
    for(int i=1;i<100005;i++)
    {
    	dp[i]=1e15;
	}
    dp[0]=0;
    int res=0;
    for(int i=0;i<n;i++){
        for(int j=1e5;j>=v[i];j--){
            dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
            if(dp[j]<=W){
                res=max(res,j);
            }
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 4400
// time limit exceeded

#include <stdio.h>
#define MAXSIZE 100

int main(void){
    int n, tl, cost[MAXSIZE], tm[MAXSIZE];
    scanf("%d %d", &n, &tl);
    
    int i;
    for(i = 0; i < n; i++){
        scanf("%d %d", &cost[i], &tm[i]);
    }

    int min_cost = 2000;
    for(i = 0; i < n; i++){
        //printf("i = %d: ", i);
        if(tm[i] <= tl && cost[i] < min_cost){
            //printf("%d < %d -> ", cost[i], min_cost);
            min_cost = cost[i];
        }
        //printf("min_cost = %d\n", min_cost);
    }

    if(min_cost == 2000){
        printf("TLE\n");
    }else{
        printf("%d\n", min_cost);
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <queue>

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(int argc, char **argv){
	int n , q;
	std::string buf;
	std::vector<std::queue<long> > ques;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif


#if INPUT_FROM_FILE
	std::getline(ifs, buf);
#else
	std::getline(std::cin, buf);
#endif
	{
		std::istringstream stream(buf);

		stream >> n >> q;
	}

	ques.resize(n);
	for(int i = 0; i < q; i++){
#if INPUT_FROM_FILE
		std::getline(ifs, buf);
#else
		std::getline(std::cin, buf);
#endif
		std::istringstream stream(buf);
		long tmp, t, x;

		if(buf[0] == '0'){
			stream >> tmp >> t >> x;

			ques[t].push(x);
		}
		else if(buf[0] == '1'){
			stream >> tmp >> t;

			if(!ques[t].empty()){
				std::cout << ques[t].front() << std::endl;
			}
		}
		else{
			stream >> tmp >> t;
			if(!ques[t].empty()){
				ques[t].pop();
			}
		}

	}

	return 0;
}



Measured memory_bytes: 5204
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int x, n;
    cin >> x >> n;
    int arr[202];
    memset(arr,0,sizeof(arr));
    int c;
    for (int i = 0; i < n; i++)
    {
        cin >> c;
        arr[c+100] = 1;
    }
    if(arr[x+100]==0){
        printf("%d\n",x);
    }
    else
    {
        for (int i = 1; i <= 101; i++)
        {
            if(arr[x-i+100]==0){
                printf("%d\n",x-i);
                return 0;
            }
            else if(arr[x+100+i]==0){
                printf("%d\n",x+i);
                return 0;
            }
        }
        
    }
    
    
    
}

Measured memory_bytes: 3756
#include <iostream>
#include <algorithm>
#include <vector>
#include<string>
#include <set>
#include <map>
#include <queue>
#include <limits.h>
#include <bitset>
#include <cmath>

using namespace std;

#define rip(i,n,s) for (int i=(s);i<(int)(n);i++)
#define all(a) (a).begin(),(a).end()
typedef long long ll;

struct mat{
    ll r;
    ll c;
};

typedef pair<ll,mat> P;

ll cal(P &x, P &y){
    return x.first+y.first+x.second.r*y.second.r*y.second.c;
}

int main(){
    int n;
    cin >> n;
    vector<mat> da(n);
    rip(i,n,0){
        cin >> da[i].r >> da[i].c;
    }
    vector<vector<P>> dp(n,vector<P>(n));
    rip(i,n,0){
        dp[i][i].first=0;
        dp[i][i].second=da[i];
    }
    rip(i,n,1){
        rip(j,n-i,0){
            dp[j][j+i].first=LLONG_MAX;
            rip(k,i,0){
                dp[j][j+i].first=min(dp[j][j+i].first,cal(dp[j][j+k],dp[j+k+1][j+i]));
            }
            dp[j][j+i].second.r=da[j].r;
            dp[j][j+i].second.c=da[j+i].c;
        }
    }
    cout << dp[0][n-1].first << endl;
}


Measured memory_bytes: 3236
#include<stdio.h>
int main(void)
{
  int n, m, c,i,j;

  scanf("%d",&n);
  scanf("%d",&m);
  scanf("%d",&c);

  int b[m];

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

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

  int ans, count;

  count=0;


  for(i=0; i<n; i++){
    ans=0;
    for(j=0; j<m; j++){
      ans += a[i][j]*b[j];
    }
    ans += c;
    if(ans>0){
      count ++;
    }
  }

  printf("%d",count);
  return 0;

}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main() {
	int n, x;
	cin >> n >> x;
	int i, j, k;
	
	while (n != 0 || x != 0) {
		int o = 0;
		
		for (i = 1; i <= n; i++) {
			for (j = i + 1; j <= n; j++) {
				for (k = j + 1; k <= n; k++) {
					if (i + j + k == x){
						o++;
						}
				}
			}
		}
		cout << o << endl;
		cin >> n >> x;
	}

	return 0;

}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793


   
int main(){
  ll n;
  cin >> n;
  ll ans=1000000000000;
  for(int i=1;i<=sqrt(n);i++){
     if(n%i==0){
        ll mx=0;
        ll a=i;
        ll b=n/a;
        int aa=1;
        while(a>=10){
           a/=10;
           aa++;
        }
        int bb=1;
        while(b>=10){
           b/=10;
           bb++;
        }
      mx=max(aa,bb);
      ans=min(ans,mx);
     }
  }
  cout << ans << endl;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main()
{
    string a, b;
    cin >> a >> b;
    for(int i = 0; i <= 2; i++){
        if(a[i] != b[2 - i]){
          cout << "NO" << endl;
          return 0;
        }
    }
  cout << "YES" << endl;
    return 0;
}


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

int main() {
  string str;
  cin >> str;

  int count = 0;
  for (int i = 0; i < 3; i++) {
    if (str.at(i) == '1') {
      count++;
    }
  }

  cout << count << endl;
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;
const int Max_M(3050);
const int Max_N(3050);
const int MOD(1000000000 + 7);
typedef long long int LL;

constexpr int Add(int a, int b)
{
	return a + b >= MOD ? a + b - MOD : a + b;
}

inline void update(int &a, int b)
{
	a = Add(a, b);
}

int N, M, F[Max_M][Max_N][2];

int main()
{
	scanf("%d%d", &N, &M);
	for (int x = 0;x <= N;++x)
		F[0][x][x == 0] = 1;
	for (int i = 0;i <= M - 1;++i)
		for (int x = 0;x <= N;++x)
			for (int c = 0;c <= 1;++c)
			{
				if (x >= 1)
				{
					update(F[i + 1][x - 1][c | (x - 1 == 0)], F[i][x][c]);
					update(F[i + 1][x][c | (x - 1 == 0)], F[i][x][c]);
				}
				if (x <= N - 1)
				{
					update(F[i + 1][x + 1][c], F[i][x][c]);
					update(F[i + 1][x][c], F[i][x][c]);
				}
			}
	int Ans(0);
	for (int x = 0;x <= N;++x)
		update(Ans, F[M][x][1]);
	printf("%d", Ans);
	return 0;
}
/*
在一轮操作结束之后，球的总数仍然是N。所以可以用一个二元组(i, x)表示到第i轮结束时，有x个红球和N - x个蓝球的情况(0 <= x <= N)
每一轮在队列后增加两个元素有四种方法：
(1)红红。需要满足x >= 1，可以看成(i, x) -> (i + 0.5, x - 1) -> (i + 1, x - 1)
(2)红蓝。需要满足x >= 1，可以看成(i, x) -> (i + 0.5, x - 1) -> (i + 1, x) 
(3)蓝蓝。需要满足x <= N - 1，可以看成(i, x) -> (i + 0.5, x) -> (i + 1, x + 1) 
(4)蓝红。需要满足x <= N - 1，可以看成(i, x) -> (i + 0.5, x) -> (i + 1, x)
把这些二元组放到平面上，一种队列实际上对应的是一条连续的折线，即只关心相邻两个点纵坐标的差、不关心具体纵坐标 
一条连续的折线上下平移后可以对应多种方案
计数本质不同的折线，可以考虑把折线不断向下平移，直到最低点在x轴上（此时显然不能向下移动）
考虑计数对应的折线的最低点在x轴上的方案数即可，可以直接dp，F[i][x][0 / 1]表示当前在(i, x)处、当前折线最低点是否在x轴上的方案数 
*/

Measured memory_bytes: 71808
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    int ans = -INF;
    chmax(ans, a + b);
    chmax(ans, a + a - 1);
    chmax(ans, b + b - 1);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main() {
    int H, W; cin >> H >> W;
    vector<vector<string>> S(H, vector<string>(W, ""));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> S[i][j];
            if (S[i][j] == "snuke") {
                char c = (char)((j + 1)  + 64);
                printf("%c%d\n", c, i + 1);
                break;
            }
        }
    }
}

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

int main() {
    bool enter_flag = true;

    int n;
    cin >> n;

    vector<int> vec(n);
    for(int i=0; i<n; i++) {
        cin >> vec[i];
    }

    for(int i=0; i<n; i++) {
        if (vec[i] % 2 == 1) continue;
        else if (vec[i] % 2 == 0) {
            if (vec[i] % 3 != 0 && vec[i] % 5 != 0) {
                enter_flag = false;
                break;
            }
        }
    }

    if (enter_flag) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;

    return 0;
}

Measured memory_bytes: 256
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

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

int main() {
    int H,W; cin >> H >> W;
    vector<string> maze(H);
    REP(i,H) cin >> maze.at(i);

    int ans = -1;

    for(int sx = 0; sx < W; sx++) {
        for(int sy = 0; sy < H; sy++) {
            vector<vector<int>> dist(H,vector<int>(W,-1));
            queue<P> que;

            if(maze[sy][sx] == '#') continue;

            dist[sy][sx] = 0;
            que.push(P(sy,sx));

            while(!que.empty()) {
                pair<int,int> v = que.front();
                que.pop();
                for(int dir = 0; dir < 4; dir++) {
                    int nx = v.second + dx[dir];
                    int ny = v.first + dy[dir];
                    if(nx < 0 || nx >= W || ny < 0 || ny >= H)continue;
                    if(maze.at(ny).at(nx) == '#') continue;
                    if(dist.at(ny).at(nx) != -1) continue;
                    dist.at(ny).at(nx) = dist.at(v.first).at(v.second) + 1;
                    que.push(make_pair(ny,nx));
                }
            }


            int max_dist = -1;
            for(int i = 0; i < W; i++) {
                for(int j = 0; j < H; j++) {
                    if(max_dist <= dist[j][i]) max_dist = dist[j][i];
                }
            }
            chmax(ans,max_dist);
        }
    }
    cout << ans << endl;
}

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

vector<int> g[222];
int c[222] = {};
bool used[222] = {};

void dfs(int now, int color){
  if(used[now]) return;
  used[now] = true;
  c[now] = color;
  for(auto p: g[now]){
    if(c[p] == color){
      cout << -1;
      exit(0);
    }
    dfs(p, 3 - color);
  }
}

int main(){
    int n;
    string s;
    cin >> n;
    if(n==2){cout<<2;return 0;}
    int dist[222][222]={};
    for(int i=0;i<n;i++)for(int j=0;j<n;j++)dist[i][j]=100000;
    for(int i=0;i<n;i++){
      cin >> s;
      for(int j = 0; j < n; j++){
        if(s[j] == '1'){
        	 g[i].push_back(j);
             dist[i][j]=dist[j][i]=1;
        }
      }
    }
    dfs(0, 1);
    for(int i=0;i<n;i++)for(int j=0;j<n;j++)for(int k=0;k<n;k++)dist[j][k]=min(dist[j][k],dist[j][i]+dist[i][k]);
    int res=0;
    for(int i=0;i<n;i++)for(int j=0;j<n;j++)res=max(res,dist[i][j]);
    cout<<res+1<<endl;
}


Measured memory_bytes: 640
Module Module1
 
    Sub Main()
 
        Dim S As String = Console.ReadLine()
        Dim tmp As String() = Split(S, " ")
        Dim N As Integer = CLng(tmp(0))
        Dim K As Integer = CLng(tmp(1))
        Dim Q As Integer = CLng(tmp(2))
        Dim t As Integer = Q - K
 
        Dim A(N) As Integer
        Dim c As Integer
 
        For c = 0 To Q - 1
            A(CLng(Console.ReadLine()) - 1) += 1
        Next
 
        For c = 0 To N - 1
            If t < A(c) Then
                Console.WriteLine("Yes")
            Else
                Console.WriteLine("No")
            End If
        Next
 
    End Sub
 
End Module

Measured memory_bytes: 18396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////


#define N 100005

int main(){fastio
    ll n;cin>>n;
    n=n/2;
    ll a[N],b[N];memset(a,0,sizeof(a));
    memset(b,0,sizeof(b));
    rep(i,0,n-1){
        ll x,y;cin>>x>>y;
        a[x]++;b[y]++;
    }
    ll ma=-1,mapos=-1;
    ll ma2=-1,ma2pos=-1;
    rep(i,0,N-1){
        if(a[i]>ma){
            ma2=ma;
            ma2pos=mapos;
            ma=a[i];
            mapos=i;
        }else if(a[i]>ma2){
            ma2=a[i];
            ma2pos=i;
        }
    }
    ll ans=0;
    rep(i,0,N-1){
        if(i==mapos){
            Max(ans,ma2+b[i]);
        }else{
            Max(ans,ma+b[i]);
        }
    }
    cout<<n*2-ans<<endl;
    
    
    return 0;
}



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

int main() {
    int n;
    string s;
    cin >> n >> s;
    for (int i = 1; i < s.size(); ++i) 
        if (s[i] == s[i-1]) --n;
    cout << n << endl;
    
    return 0;
}

Measured memory_bytes: 3752
lines = readlines.map(&:strip)

n = lines[0].to_i
red_points = lines[1..n].map{|e|e.split.map(&:to_i)}
blue_points = lines[n+1..n*2].map{|e|e.split.map(&:to_i)}

red_points.sort!
blue_points.sort!

#p red_points
#p blue_points
#p '---'

result=0
blue_points.each do|blue|
  candidate_red_points = red_points.dup.keep_if {|red| red[0] < blue[0] && red[1] < blue[1] }
  sorted_candidates = candidate_red_points.sort_by {|r| r[1] }
#  sorted_candidates = candidate_red_points.sort
  red_point = sorted_candidates.last
#  p '='
#  p blue
#  p red_point
#  p red_points
  next if red_point.nil?
  red_points.delete(red_point)
  result+=1
end

p result




Measured memory_bytes: 1916
N = int(input())

def get_divisors(n, reverse=False):
    from math import sqrt
    divisors = []
    for num in range(1, int(sqrt(n))+1):
        if n % num == 0:
            divisors.append(num)
            divisors.append(n//num)
    return sorted(divisors, reverse=reverse)

divisors = get_divisors(N)

l = len(divisors)
ans = float('inf')
for i in range(l//2):
    ans = min(ans, divisors[i] + divisors[l - 1 - i])
print(ans-2)

Measured memory_bytes: 39152
n,m=map(int,input().split())

def c(n,m):
    import math
    if n-m<0:
        return 0
    return(math.factorial(n)//math.factorial(n-m)//math.factorial(m))

def factorize(n):
    fct=[]
    b,e=2,0
    while b*b<=n:
        while n%b==0:
            n=n//b
            e=e+1
        if e>0:
            fct.append((b,e))
        b,e=b+1,0
    if n>1:
        fct.append((n,1))
    return fct

l=factorize(m)
mod=10**9+7
ans=1
for i,j in l:
    ans*=c(j+n-1,j)
    ans=ans%mod

print(ans)

Measured memory_bytes: 114140
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <sstream>
#include <ostream>
#include <bitset>
#include <list>
#include <deque>
#include <complex>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cfloat>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <climits>

using namespace std;

#define MAX_V 505
#define INF 1e9
#define rep(i,n) for(int i = 0 ; i < n ; i++)
#define FOR(i,a,b) for(int i = a ; i < b ; i++)
#define all(p) (p).begin(),(p).end() 

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;

struct edge{ int to,cap,rev; };

int V,E;
vector<edge> G[MAX_V];
int level[MAX_V],iter[MAX_V];

void add_edge(int from,int to,int cap){
  G[from].push_back((edge){to,cap,G[to].size()});
  G[to].push_back((edge){from,0,G[from].size()-1});
}

void bfs(int s){
  memset(level,-1,sizeof(level));
  queue<int> Q;
  level[s] = 0;
  Q.push(s);
  while(!Q.empty()){
    int v = Q.front(); Q.pop();
    for(int i = 0 ; i < (int)G[v].size() ; i++){
      edge &e = G[v][i];
      if(e.cap > 0 && level[e.to] < 0){
        level[e.to] = level[v] + 1;
        Q.push(e.to);
      }
    }
  }
}

int dfs(int v,int t,int f){
  if(v == t) return f;
  for(int &i = iter[v] ; i < (int)G[v].size() ; i++){
    edge &e = G[v][i];
    if(e.cap > 0 && level[v] < level[e.to]){
      int d = dfs(e.to,t,min(f,e.cap));
      if(d > 0){
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}

int max_flow(int s,int t){
  int flow = 0;
  for(;;){
    bfs(s);
    if(level[t] < 0) return flow;
    memset(iter,0,sizeof(iter));
    int f;
    while((f = dfs(s,t,INF)) > 0){
      flow += f;
    }
  }
}

int main(){
  int X,Y,E,x,y;
  scanf("%d%d%d",&X,&Y,&E);
  int s = X+Y, t = s+1;
  rep(i,X){
    add_edge(s,i,1);
  }
  rep(i,Y){
    add_edge(X+i,t,1);
  }
  rep(i,E){
    scanf("%d%d",&x,&y);
    add_edge(x,X+y,1);
  }
  printf("%d\n",max_flow(s,t));

  return 0;
}

Measured memory_bytes: 1520
//
// author  : Abhishek
//
#include <bits/stdc++.h>
#include<chrono>

#define ll long long
#define db double
#define deb(x) cout<<#x<<": "<<x<<"\n"
#define all(x) x.begin(),x.end()
#define fo(i, n) for(i=0 ; i<n ; i++)
#define Fo(i, k, n) for(i=k ; i<n ; i++)

using namespace std;
using namespace chrono;

const ll MOD = 1000000007;
const ll N = 300005;  // array size
const ll inf = 10000000000000000;


void print(vector<ll> v) {
    ll i;
    fo(i, v.size())cout << v[i] << " ";
    cout << "\n";
}

void print(vector<pair<ll, ll> > v) {
    ll i;
    fo(i, v.size()) {
        cout << v[i].first << " " << v[i].second << "\n";
    }
}

vector<ll> read(ll n) {
    ll i;
    vector<ll> arr(n, 0);
    fo(i, n)cin >> arr[i];
    return arr;
}

vector<ll> read(ll n, ll k) {
    ll i;
    vector<ll> arr(n + k, 0);
    Fo(i, k, n + k)cin >> arr[i];
    return arr;
}

bool isEven(ll n) {
    return n % 2 == 0;
}

bool isOdd(ll n) {
    return n % 2 != 0;
}


void solve() {
    ll t = 1;
//    cin >> (t);
    while (t--) {

        ll i, j, k, n, m, p, q, x, y, a, b, l, r;
        string s1, s2;
        cin >> s1 >> s2;

        n = s1.size();
        m = s2.size();
        ll dp[n + 1][m + 1];
        fo(i, n + 1) {
            fo(j, m + 1) {
                dp[i][j] = 0;
            }
        }


        Fo(i, 1, n + 1) {
            Fo(j, 1, m + 1) {
                if (s1[i - 1] == s2[j - 1]) {
                    dp[i][j] = 1 + dp[i - 1][j - 1];
                } else {
                    dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]);
                }
            }
        }


//        fo(i, n + 1) {
//            fo(j, m + 1) {
//                cout << dp[i][j] << " ";
//            }
//            cout << "\n";
//        }

        string ans = " ";
        fo(i, dp[n][m] - 1) {
            ans += ' ';
        }
        ll last = dp[n][m] - 1;

        i = n, j = m;
        while (i > 0 && j > 0) {

            if (s1[i - 1] == s2[j - 1]) {
                ans[last] = s1[i - 1];
                last--;
                i--;
                j--;
            } else if (dp[i - 1][j] > dp[i][j - 1]) {
                i--;
            } else {
                j--;
            }
        }

        cout << ans;


    }
}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif

    auto start = high_resolution_clock::now();

    solve();

    ll i, j, k, n, m, p, q, x, y, a, b, l, r;


    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop - start);
#ifndef ONLINE_JUDGE
    cerr << "Time: " << duration.count() / 1000.0 << endl;
#endif


    return 0;
}




Measured memory_bytes: 73992
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>

#define X first
#define Y second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())


//INT_MAX
//INT_MIN
//LLONG_MAX
//LLONG_MIN
//DBL_MIN
//DBL_MAX
//LDBL_MIN
//LDBL_MAX

// A-Z: 65~90
// a-z: 97~122
// |a-z| = 26

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    int n;
    cin >> n;
    if (n == 1) {
        cout << "Hello World" << endl;
    }else{
        int a, b;
        cin >> a >> b;
        cout << a + b << endl;
    }
    
    
    
    
}


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

int main(){
  string s;
  cin >> s;
  bool judge = 0;
  int count_A = 0;
  int count_B = 0;
  rep(i, s.size()){
    count_A++;
    if (s[i] == 'A'){
      break;
    }
  }
  
  for (int i = s.size()-1; i >= 0; i--){
    count_B++;
    if (s[i] == 'Z'){
      break;
    }
  }
  
  int ans = (s.size() - count_A - count_B) + 2;
  cout << ans << endl;
    
    
    
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FOR(i) for(cin>>i;i>0;i--)
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define re(x) {cout<<x<<endl;return 0;}
//#define x first
//#define y second

using namespace std;
int a;
int main()
{
	cin>>a;
	cout<<a+a*a+a*a*a<<endl;
	return 0;}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li p[1010];

int main() {
    li n;
    cin >> n;
    string res = "";
    bool first = true;
    n--;
    while (n >= 0) {
        li a = (n % 26);
        //p2(n, a);
        res = (char)(a + 'a') + res;
        n /= 26;
        if (n == 0) {
            break;
        }
        n--;
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3644
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int max = -100000;
        int min = 100000;
        for(int i=0; i<N; i++){
            int a = sc.nextInt();
            if(max < a){
                max = a;
            }
            if(min > a){
                min = a;
            }
        }
        System.out.println(max - min);
    }
}

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

int main() {
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    for(int i = 0; i <= n; i++) {
        if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') 
            ans++;
        }
    cout << ans << endl;
    return 0;
 }

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

int main() {
	cout << fixed << setprecision(8);
	for (int n; cin >> n, n;) {
		int s[1000], sum = 0;
		for (int i = 0; i < n; i++) {
			cin >> s[i];
			sum += s[i];
		}
		double m = (double)sum / n;
		double a = 0;
		for (int i = 0; i < n; i++) {
			a += (s[i] - m)*(s[i] - m);
		}
		a /= n;
		a = sqrt(a);
		cout << a << endl;
	}
	return 0;
}

Measured memory_bytes: 1236
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <utility>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_map>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const int MOD = 1000000007;
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; }

int main() {
    int a, b;
    cin >> a >> b;
    if(a > b) cout << "a > b" << endl;
    else if(a < b) cout << "a < b" << endl;
    else cout << "a == b" << endl;

    return 0;
}


Measured memory_bytes: 3092
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n,m,e,j;
	char z;
	while(true){
	cin>>n;
	if(n==0)
		break;
	for(int i=0;i<n;i++){
		cin>>m>>e>>j;
		z='C';
		if(m+e+j>=210)
			z='B';
		if(m+e+j>=150&&(m>=80||e>=80))
			z='B';
		if(m==100||e==100||j==100)
			z='A';
		if(m+e>=180)
			z='A';
		if(m+e+j>=240)
			z='A';
		cout<<z<<endl;
	}
	}
    return 0;
}
 

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

typedef long long ll;
ll MOD = 1000000007;

typedef long long ll;

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

    for (int i = 0; i < s.size(); i++) {
        if (s[i] == s[i+1]) {
            cout << i+1 << " " << i+2 << endl;
            return 0;
        }
    }
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == s[i+2]) {
            cout << i+1 << " " << i+3 << endl;
            return 0;
        }
    }
    cout << -1 << " " << -1 << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
typedef long long lint;
const int N=1e5+5;
int n,v1[N],v2[N],v3[N];
lint res[N];

namespace utils{
	template <class T> inline void apn(T &x,const T y){x=x<y?x:y;}
	template <class T> inline void apx(T &x,const T y){x=x<y?y:x;}
	inline int nxi(){
		int x=0;
		char c;
		while(((c=getchar())>'9'||c<'0')&&c!='-');
		const bool f=(c=='-')&&(c=getchar());
		while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

int main(){
#ifdef LOCAL
	freopen("snuke.in","r",stdin);
	freopen("snuke.out","w",stdout);
#endif
	n=nxi();
	for(int i=1; i<=n; ++i)
		v1[i]=nxi();
	for(int i=1; i<=n; ++i)
		v2[i]=nxi();
	for(int i=1; i<=n; ++i)
		v3[i]=nxi();
	std::sort(v1+1,v1+n+1);
	std::sort(v2+1,v2+n+1);
	std::sort(v3+1,v3+n+1);
	for(int i=1,j=1; i<=n; ++i){
		while(j<=n&&v1[j]<v2[i]) ++j;
		res[i]=res[i-1]+j-1;
	}
	lint ans=0;
	for(int i=1,j=1; i<=n; ++i){
		while(j<=n&&v2[j]<v3[i]) ++j;
		ans+=res[j-1];
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
static const long double GRATIO=(long double)(1+sqrt(5))/2;
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;
}
int main(){
    int N;
    cin>>N;
    vector<ll> A(N);
    rep(i,N) cin>>A[i];
    vector<ll> sum(N+1,0);
    map<ll,ll> num;
    rep(i,N) sum[i+1]=sum[i]+A[i];
    sort(sum.begin(),sum.end());
    rep(i,N+1) num[sum[i]]++;
    ll ans=0;
    for(auto i=num.begin(); i!=num.end(); i++){
        ll s=i->second;
        ans+=s*(s-1)/2;
    }
    cout<<ans<<endl;
}

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

  int N;
  cin >> N;
  
  vector<tuple<string, int, int>> SP;
  
  for(int i=0;i<N;i++){
    string Si;
    int Pi;
    
    cin >> Si >> Pi;
    SP.push_back(make_tuple(Si, -1*Pi, i+1));
  }
  
  sort(SP.begin(), SP.end());
  

  for(int i=0;i<N;i++){
    string x;
    int y,z;
    tie(x,y,z)=SP.at(i);
    cout <<z<<endl;  
  }

}

Measured memory_bytes: 256