akhauriyash/Code-Regression huggingface dataset:
//start of jonathanirvings' template v3.0.3 (BETA)

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

typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<LL> vl;
typedef vector<vl> vvl;

double EPS = 1e-9;
int INF = 1000000005;
long long INFF = 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};

#ifdef TESTING
  #define DEBUG fprintf(stderr,"====TESTING====\n")
  #define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
  #define debug(...) fprintf(stderr, __VA_ARGS__)
#else
  #define DEBUG 
  #define VALUE(x)
  #define debug(...)
#endif

#define FOR(a,b,c) for (int (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define FORD(a,b,c) for (int (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (int (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define REP(i,n) FOR(i,0,n)
#define REPN(i,n) FORN(i,1,n)
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define SQR(x) ((LL)(x) * (x))
#define RESET(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(),v.end()
#define ALLA(arr,sz) arr,arr+sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr,sz) sort(ALLA(arr,sz))
#define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)

inline string IntToString(LL a){
  char x[100];
  sprintf(x,"%lld",a); string s = x;
  return s;
}

inline LL StringToInt(string a){
  char x[100]; LL res;
  strcpy(x,a.c_str()); sscanf(x,"%lld",&res);
  return res;
}

inline string GetString(void){
  char x[1000005];
  scanf("%s",x); string s = x;
  return s;
}

inline string uppercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
  return s;
}

inline string lowercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
  return s;
}

inline void OPEN (string s) {
  #ifndef TESTING
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
  #endif
}

//end of jonathanirvings' template v3.0.3 (BETA)

string s,t;
LL risan = 1;
LL MOD = 1e9 + 7;
int n;

int kons(int a,int b)
{
  if (a == 0)
  {
    if (b == 1) return 6;
    return 3;
  } else if (a == 1)
  {
    if (b == 1) return 3;
    return 1;
  } else 
  {
    if (b == 1) return 2;
    return 2;
  }
}

int last = 0;

int main()
{
  scanf("%d",&n);
  s = GetString();
  t = GetString();
  REP(i,n)
  {
    if (s[i] == t[i])
    {
      risan = risan * kons(last, 2) % MOD;
      last = 2;
    } else 
    {
      risan = risan * kons(last, 1) % MOD;
      last = 1;
      ++i;
    }
  }
  printf("%lld\n",risan);
  return 0;
}










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

using namespace std;

int main() {
  int n, x;
  std::cin >> n >> x;

  int64_t ret = 0;
  int prev_a;
  std::cin >> prev_a;
  int a;
  while (std::cin >> a) {
    int const eat = std::max(prev_a + a - x, 0);
    ret += eat;
    prev_a = a - std::min(eat, a);
  }
  std::cout << ret << std::endl;
  return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<cstring>
using namespace std;
int pre(int a,int b)
{
	int m;
	while(a>0)
	{
		m=b%a;
		b=a;
		a=m;
	}
	return b;
}
bool f(int a[],int T)
{
	for(int i=0;a[i];i++)
	{
		
		if(a[i]%T!=0)
			return 0;
	}
	return 1;
}
int main()
{
	int ans[100000+5],K,N,e=0,j=0;
	memset(ans,0,sizeof(ans));
	cin>>N>>K;
	for(int i=0;i<N;i++)
	{
		scanf("%d",&ans[i]);
		if(K==ans[i]){
			printf("POSSIBLE\n");
			return 0;
		}
		else if(ans[i]%2==0)
			e=1;
		else
			j=1;
		
	}
	
	sort(ans,ans+N);
	if(K>ans[N-1])
	{
		printf("IMPOSSIBLE\n");
		return 0;
	}
	int T=pre(ans[0],ans[1]);
	if(f(ans,T))
	{
		if(K%T==0)
		{
			printf("POSSIBLE\n");
			return 0;
		}
		else
		{
			printf("IMPOSSIBLE\n");
			return 0;
		}
	}
	else
	{
		if(e+j==2)
		{
			printf("POSSIBLE\n");
			return 0;
		}
		else if(K%2==0)
		{
			printf("POSSIBLE\n");
			return 0;
		}
	}
	printf("IMPOSSIBLE\n");
	return 0;
}

Measured memory_bytes: 640
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;

LL n;
LL a[55];
int main(){
    cin >> n;
    REP(i, n){
        cin >> a[i];
    }
    LL minl = HINF<LL>();
    REP(i, n)minl = min(minl, a[i]);
    LL ans = 0;
    if(minl >= n){
        ans += n * (minl - (n - 1));
        REP(i, n)a[i] -= (minl - (n - 1));
    }
    sort(a, a + n);
    reverse(a, a + n);
    while(a[0] >= n){
        LL cnt = a[0] / n;
        ans += cnt;
        a[0] -= n * cnt;
        for(int i = 1;i < n;i++){
            a[i] += cnt;
        }
        sort(a, a + n);
        reverse(a, a + n);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    int n,m,tmp1,tmp2,mn=0,mx;
    cin >> n >> m;
    mx=n-1;
    rep(i,m){
        cin >> tmp1 >> tmp2;
        mn=max(tmp1-1,mn);
        mx=min(mx,tmp2-1);
    }
    cout << max(0,mx-mn+1) << 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 reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;

/*
*/

ll a,b,ans=0;

void init(){
	cin>>a>>b;
}

int main(void){
	init();
	if(a>=13){
		ans=b;
	}else if(a>=6){
		ans=b/2;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int m,f,r;
  cin >> m >> f >> r;
  while(m!=-1||f!=-1||r!=-1){
    if(m==-1||f==-1) cout << "F" << endl;
    else if(m+f>=80) cout << "A" << endl;
    else if(m+f>=65) cout << "B" << endl;
    else if(m+f>=50) cout << "C" << endl;
    else if(m+f>=30)
      if(r>=50) cout << "C" << endl;
      else cout << "D" << endl;
    else cout << "F" << endl;

    cin >> m >> f >> r;
  }
  return 0;
}





Measured memory_bytes: 3084
while True:
    m,f,r = map(int,raw_input().split())
    if m == -1 and f == -1 and r == -1:
        break
    if m == -1 or f == -1:
        print "F"
    elif m+f >= 80:
        print "A"
    elif m+f >=65:
        print "B"
    elif m+f >=50 or (m+f >=30 and r >=50):
        print "C"
    elif m+f >=30:
        print "D"
    else:
        print "F"

Measured memory_bytes: 4212
#include <stdio.h>

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

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

int main(void) {
    int N;
    int i;
    
    cin >> N;
    
    vector<int> A(N);
    for (i = 0; i < N; i ++) {
        cin >> A[i];
    }
    
    
    for (i = 0; i < N; i ++) {
        if (A[i] % 2 == 0) {
            if (A[i] % 5 != 0 && A[i] % 3 != 0) {
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int M;
  cin >> M;

  cout << 24 + (24-M) << endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();

    int count = 3;

    if (a == b && b == c && c == a) {
      System.out.println(1);
    } else {
      if (a == b) count--;
      if (b == c) count--;
      if (c == a) count--;

      System.out.println(count);
    }
  }

}


Measured memory_bytes: 21844
package main

import (
	"fmt"
)

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

	var k int
	var s int

	a := make([]int, n) //スイッチごとのつながっている電球を表すビット列
	for i := 0; i < m; i++ {
		fmt.Scan(&k)

		for j := 0; j < k; j++ {
			fmt.Scan(&s)
			s--
			a[s] |= 1 << uint(i)

		}
	}

	var x int
	p := 0
	for i := 0; i < m; i++ {
		fmt.Scan(&x)

		p |= x << uint(i)
	}

	//スイッチの全パターン網羅
	ans := 0
	for s := 0; s < (1 << uint(n)); s++ {
		t := 0

		for i := 0; i < n; i++ {
			if s>>uint(i)&1 == 1 {
				t ^= a[i]
			}
		}

		if t == p {
			ans++
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
macro_rules! get_tuple {
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };

    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get_tuple!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (a, b) = get_tuple!(i64, f64);
    let b_100 = (b * 100. + 1e-12) as i64;
    let ans_100 = a * b_100;
    let ans = ans_100 / 100;

    dbg!(b_100, ans_100, ans);

    println!("{}", ans)
}


Measured memory_bytes: 2204
#pragma GCC optimize("Ofast","inline")
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define next Next
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"-----------------"#x"-----------------\n"
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
                    For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int,int> pii;
LL read(){
    LL x=0,f=0;
    char ch=getchar();
    while (!isdigit(ch))
        f=ch=='-',ch=getchar();
    while (isdigit(ch))
        x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return f?-x:x;
}
const int N=100010*2;
int n,m,r;
vector <pair <int,int> > ans;
int vis[N];
int main(){
	n=read();
	if (n<=2)
		return puts("No"),0;
	m=n/4-1;
	r=n%4;
	ans.pb(mp(1,2));
	ans.pb(mp(2,3));
	ans.pb(mp(3,n+1));
	ans.pb(mp(n+1,n+2));
	ans.pb(mp(n+2,n+3));
	For(i,1,m){
		ans.pb(mp(i*4,i*4+1));
		ans.pb(mp(i*4+1,i*4+2));
		ans.pb(mp(i*4+2,i*4+3));
		ans.pb(mp(i*4+3,n+i*4));
		ans.pb(mp(n+i*4,n+i*4+1));
		ans.pb(mp(n+i*4+1,n+i*4+2));
		ans.pb(mp(n+i*4+2,n+i*4+3));
	}
	if (n>3){
		int t=4*(m+1);
		if (r==0){
			vector <int> id;
			For(i,2,20)
				if (n>>i&1)
					id.pb(1<<i);
			sort(id.begin(),id.end());
			if (id.back()>=n)
				return puts("No"),0;
			For(i,1,(int)id.size()-1){
				vis[id[i]]=1;
				ans.pb(mp(id[i],id[i-1]));
			}
			For(i,1,m)
				if (!vis[i*4])
					ans.pb(mp(i*4,1));
			ans.pb(mp(id[0],n+n));
			ans.pb(mp(id.back(),n));
		}
		else if (r==1){
			For(i,1,m)
				ans.pb(mp(i*4,1));
			ans.pb(mp(t,t+1));
			ans.pb(mp(t+1,1));
			ans.pb(mp(1,n+t));
			ans.pb(mp(n+t,n+t+1));
		}
		else if (r==2){
			For(i,1,m)
				ans.pb(mp(i*4,1));
			ans.pb(mp(t,t+1));
			ans.pb(mp(t+1,1));
			ans.pb(mp(1,n+t));
			ans.pb(mp(n+t,n+t+1));
			ans.pb(mp(t+2,t+1));
			ans.pb(mp(2,n+t+2));
		}
		else {
			For(i,1,m)
				ans.pb(mp(i*4,1));
			ans.pb(mp(t,t+1));
			ans.pb(mp(t+1,1));
			ans.pb(mp(1,n+t));
			ans.pb(mp(n+t,n+t+1));
			ans.pb(mp(t+2,t+1));
			ans.pb(mp(2,n+t+2));
			ans.pb(mp(t+3,n+t+2));
			ans.pb(mp(3,n+t+3));
		}
	}
	puts("Yes");
	for (auto p : ans)
		printf("%d %d\n",p.fi,p.se);
	return 0;
}

Measured memory_bytes: 4336
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = 1234567;

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}

int main(void){
	string s,t;
	cin>>s;
	cin>>t;
	int n = s.size();

	vector<vector<int>> next;
	rep(i,1e5+3){
		next.push_back(vector<int>());
		rep(j,26){
			next[i].push_back(-1);
		}
	}


	rep(i,s.size()){
		next[(i-1+n)%n][s[i] - 'a'] = i;
	}

	rep(hoge, 2){
		REP(i,s.size()){
			rep(j,26){
				if(next[i][j] != -1 && next[(i-1+n)%n][j] == -1){
					next[(i-1+n)%n][j] = next[i][j];
				}
			}
		}
	}
	/*cerr<<"hoge"<<endl;
	rep(i,26){
		cerr<<(char)('a'+i)<<" ";
	}
	cerr<<endl;
	rep(i,s.size()){
		rep(j,26){
			cerr<<next[i][j]<<" ";
		}
		cerr<<endl;
	}*/

	ll ans = 0;
	int si = n-1;
	rep(ti, t.size()){
		int si_next = next[si][t[ti] - 'a'];
		if(si_next == -1){
			cout<<-1<<endl;
			return 0;
		}
		ans += si_next - si;
		if(si_next <= si){
			ans += n;
		}
		si = si_next;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 17456
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int a,b;
    cin >> a >> b;
    vector<vector<char>> ans(100, vector<char>(100));
    rep(i,100) rep(j,100) ans[i][j] = '.';
    int i = 0;
    bool ch = false;
    a--;
    while(a){
        ch = true;
        for(int j = 0; j < 100; j += 2){                
            if (a == 0) break;
            ans[i][j] = '#';
            a--;
        }
        for(int j = 0; j < 100; j++){
            ans[i+1][j] = '#';
        }
        i += 2;
    }

    if (ch) b--;
    i++;
    while(b){
        for(int j = 0; j < 100; j+= 2){
            if (b == 0) break;
            ans[i][j] = '#';
            b--;
        }
        i += 2;
    }

    printf("100 100\n");
    rep(i,100){
        rep(j,100){
            cout << ans[i][j];
        }
        cout << endl;
    }
    return 0;
}

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

freq = {}
for i in range(m):
  p, s = input().split()
  if not p in freq:
    freq[p] = [0, 0]
  if freq[p][0] == 0:
    freq[p][['AC', 'WA'].index(s)] += 1

print(sum(c for c, w in freq.values() if c > 0), sum(w for c, w in freq.values() if c > 0))


Measured memory_bytes: 67032
#include<bits/stdc++.h>
using namespace std;
int n, m, res = 0;
vector <int> x[100001];
int main () {
  ios_base :: sync_with_stdio (0);
  cin.tie (nullptr);
  cout.tie (nullptr);
  cin >> n >> m;
  for (int i = 1; i <= n; ++ i) {
    int a, b;
    cin >> a >> b;
    if (a <= m) {
      x[m - a].push_back (b);
    }
  }
  priority_queue <int> q;
  for (int i = m - 1; i >= 0; -- i) {
    for (int v : x[i]) {
      q.push (v);
    }
    if (q.size ()) {
      res += q.top ();
      q.pop ();
    }
  }
  cout << res;
}


Measured memory_bytes: 5632
s = list(input())
q = int(input())
for i in range(q) :
    order = list(input().split())
    if order[0] == "print" :
        for n in range(int(order[1]), int(order[2])+1) :
            print(s[n], sep="", end="")
        print()
        
    elif order[0] == "reverse" :
        new_s = s[int(order[1]) : int(order[2])+1]
        new_s.reverse()
        s[int(order[1]) : int(order[2])+1] = new_s
    
    elif order[0] == "replace" :
        s[int(order[1]) : int(order[2])+1] = list(order[3])


Measured memory_bytes: 5716
#include<bits/stdc++.h>
using namespace std;
#define ALL(A) A.begin(),A.end()
const long long mod=1000000007;
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a>b)
    {
        if(c>d)
        cout<<b+d<<endl;
        else
        cout<<b+c<<endl;
    }
    else
    {
        if(c>d)
        cout<<a+d<<endl;
        else
        cout<<a+c<<endl;
    }
    return 0;
}

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

int main(){
     int N;
     int M;
     int X;
     int A[100];
     int checkup = 0;
     int checkdown = 0;

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

     for(int n = 0; n < M; n++){
        if(A[n] < X){checkdown +=1;}else if(A[n] > X){checkup +=1;}
     }

     if(checkup >= checkdown){
       printf("%d\n",checkdown);
     }else{
       printf("%d\n",checkup);
     }
     return 0;
}

Measured memory_bytes: 128
from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd
# fractions.gcd() を用いること
# math.log2()はatcoderでは対応していない．留意せよ．

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def find_gcd(list_l):
    x = reduce(gcd, list_l)
    return x


def main():
    x,y,a,b,c = map(int,input().strip().split())
    p = list(map(lambda x : (int(x),0), input().strip().split())) 
    q = list(map(lambda x : (int(x),1), input().strip().split())) 
    r = list(map(lambda x : (int(x),2), input().strip().split())) 
    l = sorted((p+q+r),reverse=True)
    
    # eprint('l ',end=':\n')
    # eprint(l)
    
    n=x+y
    ans=0
    for i in range(len(l)):
        if n==0:
            break

        if (l[i][1]==0 and x==0) or (l[i][1]==1 and y==0):
            continue
        else:
            ans+=l[i][0]
            n-=1
            if l[i][1]==0:
                x = max(x-1,0)
            if l[i][1]==1:
                y = max(y-1,0)
    print(ans)


if __name__ == '__main__':
    main()

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

using namespace std;

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

#define ALL(obj)	(obj).begin(),(obj).end()

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

typedef pair<int,int>			P;
typedef vector<int>				V;
typedef vector<V>				VV;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define MAX 		2505

const ll LINF = (ll)1e18+7;		//
const int INF = 1e9+7;			//2,147,483,647 (Max int)
const int MOD = 1e9+7;
// テンプレ終了
//====================================================================//

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

	int N = s.size();

	ll ans = 0;

	char color = s[0];
	REPS(i,1,N){
		if(color != s[i]){
			ans++;
			color = s[i];
		}
	}

	cout << ans << endl;

	return 0;
}




Measured memory_bytes: 512
//Heaplax
#include<bits/stdc++.h>
#define LL long long
#define low(x) ((x)&-(x))
#define LOG(x) cerr<<#x<<" = "<<x<<endl
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;
}
using namespace std;
const int mod=1000000007;
int f[2][21][(1<<20)+1];
int n,m,k;
int mark[21][21];
void add(int& a,int b)
{
	a=a+b<mod?a+b:a+b-mod;
}
int main()
{
	re(n),re(m),re(k);
	memset(mark,-1,sizeof mark);
	for(int a,b,c;k--;)
	{
		re(a),re(b),re(c);
		mark[a][b-1]=c;
	}
	f[0][n-1][0]=1;
	for(int i=1;i<=m;++i)
	{
		bool b=i&1;
		for(int j=0;j<(1<<n);++j)f[b][0][j]=f[!b][n-1][j],f[!b][n-1][j]=0;
		for(int j=0;j<n-1;++j)
			for(int k=0;k<(1<<n);++k)if(f[b][j][k])
			{
				if(!~mark[i][j] || mark[i][j]==(k>>j&1))
					add(f[b][j+1][k],f[b][j][k]);
				if(mark[i][j]!=0 && !(k>>j&1))
				{
					int w=k-(low(k>>j+1)<<j+1)+(1<<j);
					add(f[b][j+1][w],f[b][j][k]);
				}
				f[b][j][k]=0;
			}
	}
	int ans=0;
	for(int i=0;i<(1<<n);++i)
		add(ans,f[m&1][n-1][i]);
	printf("%d\n",ans);
}


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

typedef long long ll;

ll dp[110][20][1010];

int main() {
	dp[0][0][0] = 1;
	dp[0][1][0] = 1;
	for(int i = 1; i < 110; i++) {
		dp[i][0][0] = 1;
		for(int j = 1; j < 20; j++) {
			for(int k = 0; k < 1010; k++) {
				dp[i][j][k] += dp[i-1][j][k];
				if(k-i >= 0)
					dp[i][j][k] += dp[i-1][j-1][k-i];
			}
		}
	}
	/*
	for(int i = 0; i < 10; i++) {
		for(int j = 0; j < 10; j++) {
			for(int k = 0; k < 10; k++)
				cout << dp[i][j][k] << " ";
			cout << endl;
		}
		cout << endl;
	}
	// */
	int n, s;
	while(cin >> n >> s, n || s)
		cout << dp[100][n][s] << endl;
}

Measured memory_bytes: 18300
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
using T = tuple<double, double, double>;
 
//1-indexであることに注意
struct BIT {
    int n;
    vector<int> data;
 
    BIT(int n) : n(n), data(n + 1, 0) {}
 
    int sum(int i) {
        int s = 0;
        while (i > 0) {
            s += data[i];
            i -= i & -i;
        }
        return s;
    }
 
    void add(int i, int x) {
        while (i <= n) {
            data[i] += x;
            i += i & -i;
        }
    }
};
 
int inv(vector<int>& a) {
    int res = 0;
    BIT b(a.size());
    for (int i = 0; i < a.size(); i++) {
        res += i - b.sum(a[i] + 1);
        b.add(a[i] + 1, 1);
    }
    return res;
}
 
double solve(vector<T>& p, int lim) {
    double ok = 1e9, ng = -1e9 - 1;
    vector<int> idx(p.size());
    for (int i = 0; i < p.size(); i++) {
        idx[i] = i;
    }
    for (int loop = 0; loop < 100; loop++) {
        double mid = (ok + ng) / 2;
        auto comp = [&](const int& i1, const int& i2) {
            double a1, b1, c1, a2, b2, c2;
            tie(a1, b1, c1) = p[i1];
            tie(a2, b2, c2) = p[i2];
            double y1 = (-a1 * mid + c1) / b1;
            double y2 = (-a2 * mid + c2) / b2;
            return y1 < y2;
        };
        sort(idx.rbegin(), idx.rend(), comp);
        if (inv(idx) >= lim) ok = mid;
        else ng = mid;
    }
    return ok;
}
 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int lim = (n * (n - 1) + 3) / 4;
    vector<T> p(n);
    for (int i = 0; i < n; i++) {
        cin >> get<0>(p[i]) >> get<1>(p[i]) >> get<2>(p[i]);
    }
    sort(p.begin(), p.end(), [](const T& t1, const T& t2){return -get<0>(t1) / get<1>(t1) < -get<0>(t2) / get<1>(t2);});
    double ansx = solve(p, lim);
    for (int i = 0; i < n; i++) {
        swap(get<0>(p[i]), get<1>(p[i]));
    }
    sort(p.begin(), p.end(), [](const T& t1, const T& t2){return -get<0>(t1) / get<1>(t1) < -get<0>(t2) / get<1>(t2);});
    double ansy = solve(p, lim);
    cout << fixed << setprecision(10) << ansx << " " << ansy << endl;
    return 0;
}

Measured memory_bytes: 1536
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

char board[510][510];
int row[510], col[510];
signed main() {
    int N; cin >> N;

    int cnt_black = 0;
    for(int i=0; i<N; i++) {
        for(int j=0; j<N; j++) {
            cin >> board[i][j];
            if(board[i][j] == '#') {
                cnt_black++;
                row[i]++;
                col[j]++;
            }
        }
    }

    if(cnt_black == 0) {
        cout << -1 << endl;
    }
    else {
        int mi = INF;
        for(int i=0; i<N; i++) {
            if(col[i] > 0) {
                int val = N - row[i];
                mi = min(mi, val);
            }
            else {
                int val = N - row[i] + 1;
                mi = min(mi, val);
            }
        }

        int ans = mi;
        for(int i=0; i<N; i++) {
            ans += (col[i] < N);
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 512
n = int(input())
button = [0]
for _ in range(n):
    button.append(int(input()))

visited = set()
res = 0
cur = 1
while True:
    if cur == 2:
        print(res)
        exit()
    if cur in visited:
        print(-1)
        exit()
    visited.add(cur)
    cur = button[cur] 
    res += 1

    



Measured memory_bytes: 13216
mod = 998244353
n = int(input())
a = list(map(lambda x: ord(x)%3, list(input())))
g = [list() for _ in range(3)]
for i in range(3*n):
  g[a[i]].append(i)
l = [0]*3*n
for i in range(n):
  a, b, c = sorted([g[0][i], g[1][i], g[2][i]])
  l[b] = 1
  l[c] = 2
ans = 1
for i in range(n):
  ans = ans * (i+1) % mod
c = 0
for x in l:
  if x == 0:
    c += 1
  elif x == 1:
    ans = ans * c % mod
    c -= 1
for x in reversed(l):
  if x == 2:
    c += 1
  elif x == 1:
    ans = ans * c % mod
    c -= 1
print(ans)

Measured memory_bytes: 21068
#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
    
    #define fio ios_base::sync_with_stdio(false), cin.tie(NULL)
    #define ll long long int
    #define ull unsigned long long int
    #define ld long double
    #define sb __builtin_popcount
    #define vi vector<int>
    #define vl vector<ll>
    #define vc vector<char>
    #define ii pair<int, int>
    #define pq priority_queue<ii, vector<ii>, greater<ii>>
    #define vii vector<ii>
    #define viii vector<tuple<ll, ll, ll>>
    #define sz(a) int((a).size())
    #define f(a, b) for (int i = a; i < b; i++)
    #define fr(a, b) for (int i = a - 1; i >= b; i--)
    #define tr(x, m) for (auto x : m)
    #define in(a, b) (b.find(a) != string::npos)
    #define minin(a) *min_element(all(a))
    #define maxin(a) *max_element(all(a))
    #define bs(l, h, k) equal_range(l, h, k);
    #define X first
    #define Y second
    #define fill(a, x) memset(a, x, sizeof(a))
    #define pb push_back
    #define pf push_front
    #define mp make_pair
    #define all(v) v.begin(), v.end()
    #define rall(v) reverse(v.begin(), v.end())
    #define unq(v) v.erase(unique(all(v)), v.end())
    #define el "\n"
    #define mx3(a, b, c) max(max(a, b), c)
    #define S(v) accumulate(all(v), (ll)0)
    #define IP(v1, v2) inner_product(all(v1), v2.begin(), (ll)0)
    
    const long double PI = atan(1.0) * 4.0;
    const ll MOD = 1e9 + 7;
    const ll INF = 1e18;
    const ld EPS = 0.0000001;
    #define N 100005   
        bool pal(string s){
            for(int i=0;i<=s.length()/2;i++){
                if(s[i]!=s[s.length()-i-1])return false;
            }
            return true;
        }
        int main() {
            fio;
            ld n;
            cin>>n;
            ld sd = (ld)n/3;
            ld ans = (ld)sd*sd*sd;
             std::cout << std::fixed;
            cout << std::setprecision(9) << ans << '\n';
            return 0;
        }


Measured memory_bytes: 256
import Data.Bits
import Data.List
import Control.Monad
import qualified Data.Vector.Unboxed as V
import Control.Monad.ST
import Data.Maybe (fromMaybe)
import qualified Data.ByteString.Lazy.Char8 as B
import Debug.Trace

main :: IO ()
main = do
  [n,l] <- map read.words <$> getLine :: IO [Int]
  
  let as = sortOn abs [l + i - 1| i <- [1..n]]
  print $ sum (tail as)


Measured memory_bytes: 508
#include <algorithm>
#include <cmath>
#include <iostream>

using namespace std;

int64_t f(int64_t b, int64_t n)
{
    if (n == 0)
    {
        return 0;
    }
    return f(b, n / b) + n % b;
}

int main()
{
    int64_t n, s;
    cin >> n >> s;

    int64_t rn = (int64_t)floor(sqrt(n));
    for (int64_t i = 2; i <= rn; i++)
    {
        if (f(i, n) == s)
        {
            cout << i << endl;
            return 0;
        }
    }

    int64_t bmin = n + 1;
    for (int64_t p = 1; p < rn; p++)
    {
        int64_t q = s - p;
        if (q >= 0 && (n - q) % p == 0)
        {
            int64_t b = (n - q) / p;
            if (q < b && rn < b && b < n)
            {
                bmin = min(bmin, b);
            }
        }
    }
    if (bmin != n + 1)
    {
        cout << bmin << endl;
        return 0;
    }

    if (s == 1)
    {
        cout << max(n, 2L) << endl;
    }
    else if (s == n)
    {
        cout << n + 1 << endl;
    }
    else
    {
        cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<list>
//#include<unordered_map>
using namespace std;
#define ll long long
#define dd cout<<endl
#define lll __int128
const int inf=1e9+7;
const int mod=1e9+7;

const int maxn=2e5+10;

int num[maxn];

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    
    int n;
    
    cin>>n;
    
    for(int i=1;i<=n;i++)
    	cin>>num[i];
    
    int now=1;
    
    for(int i=1;i<=n;i++)
    {
    	if(num[i]==now)
    	{
    		now++;
		}
	}
	
	if(now==1)
		return cout<<-1<<endl,0;
	
	return cout<<n-now+1<<endl,0;
    
    return 0;
}

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

int main(void) {
  int n, x, y;
  
  cin >> n >> x >> y;
  
  int l[3000];
  
  for(int i = 0; i < n; i++) {
    for(int j = i+1; j < n; j++) {
      int len1 = j-i-1;
      int len2 = abs(x-i-1) + abs(y-j-1);
      int len3 = abs(y-i-1) + abs(x-j-1);
      l[min({len1, len2, len3})]++;
    }
  }
  
  for(int i = 0; i < n-1; i++) {
    cout << l[i] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
// namespace mp = boost::multiprecision;
// using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
// using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  ll a,b;
  ll ans=0;
  cin>>a>>b;
  if(a>12)ans=b;
  else if(a>5)ans=b/2;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

string line;
bool flag[10] = {};

int dfs(int i) {
    int count = 0;
    for(int j = 0; j < line.size(); j++) {
        flag[i+j] = true;
        if(line[i+j] == 'A' || line[i+j] == 'T' || line[i+j] == 'G' || line[i+j] == 'C') count++;
        else break;
    }
    return count;
}

int main() {
    cin >> line;
    int max_size = 0;
    for(int i = 0; i < line.size(); i++) {
        if(!flag[i]){
            int size = dfs(i);
            if(size > max_size) max_size = size;
        }
    }
    cout << max_size << endl;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
#define LL long long
#define dl double
template <class T>
void rd(T &x){
  x=0;T f=1;char ch=getchar();
  while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
  while(ch<='9' && ch>='0')x=x*10+ch-'0',ch=getchar();x*=f;
}
const int N=2e5+10;
using namespace std;
int n;
vector<int>S[N];
int main(){
 // freopen("in.txt","r",stdin);
 // freopen("o.txt","w",stdout);
 rd(n);
 for(int i=1;i<n;i++){
  int u,v;rd(u);rd(v);
  if(u>v)S[u].push_back(v);
  else S[v].push_back(u);
 }
 for(int i=1;i<=n;i++)sort(S[i].begin(),S[i].end()),S[i].push_back(i);
 LL ans=0;
 for(int i=1;i<=n;i++){
  int lst=1;
  for(int j=0;j<S[i].size();j++){
   ans+=1ll*(S[i][j]-lst+1)*(2+j-S[i].size())*(n-i+1);
   lst=S[i][j]+1;
  }
 }
 printf("%lld\n",ans);
 return 0;
}
/**/

Measured memory_bytes: 14748
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int x = sc.nextInt();  //動物の数
    int y = sc.nextInt();  //足の総数

    if (y % 2 == 1) {
      System.out.println("No");
      return;
    }

    for (int i = 0; i <= x; i++) {
      if ((2 * i + 4 * (x - i)) == y) {
        System.out.println("Yes");
        return;
      }
    }

    System.out.println("No");
  }
}


Measured memory_bytes: 27076
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
int main()
{
int res=0;
char s[6];
scanf("%s",s);
for(int i=0;i<4;i++)
{
if(s[i]=='+')
res++;
else
res--;
}
printf("%d",res);
    return 0;
}


Measured memory_bytes: 256
N = int(input())
li = list(map(int, input().split()))

num_swap = 0
flag = 1

while flag:
    flag = 0
    for j in reversed(range(N - 1)):
        if li[j + 1] < li[j]:
            temp = li[j + 1]
            li[j + 1] = li[j]
            li[j] = temp
            flag = 1
            num_swap += 1

print(*li)
print(num_swap)



Measured memory_bytes: 5604
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0, _n = (int)(n); i < _n; ++i)
const int N = (int) 0, mod = (int) 0;

int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string s;
    cin >> s;
    int mx = 0, cur = 0;
    for (int i = (int) s.size() - 1; i >= 0; --i) {
        if (s[i] == 'S') cur++;
        else cur--;
        mx = max(mx, cur);
    }
    cout << mx * 2;

}


Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
#define int long long

const int N = 110;
int x[N],y[N];
int dp[N][N];

int matrix(int l,int r){
  if(dp[l][r] > -1) return dp[l][r];
  int res = (1 << 30);
  for(int i = l; i < r; i++){
    res = min(res,matrix(l,i)+matrix(i+1,r)+y[l]*x[i]*x[r]);
  }
  return dp[l][r] = res;
}

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

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

  fill(dp[0],dp[N],-1);
  for(int i = 0; i < N; i++) dp[i][i] = 0;
  cout << matrix(0,n-1) << endl;

  return 0;
}



Measured memory_bytes: 3308
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int[] P = nextIntArray1origin(sc, N);

		sc.close();

		int ans = 0;

		int min = Integer.MAX_VALUE;

		for (int i = 1; i <= N; i++) {
			if (min > P[i]) {
				ans++;
				min = P[i];
			}
		}
		out.println(ans);

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

	@SuppressWarnings("unused")
	private int[] nextIntArray1origin(Scanner sc, int n) {
		int[] result = new int[n + 1];
		for (int i = 1; i <= n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}
}


Measured memory_bytes: 81180
#include <iostream>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

int main(void)
{
    int64_t a;

    std::cin >> a;

    std::cout << a + a*a + a*a*a << std::endl;

    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

// chmax, chmin
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;
}

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T &data, vector<int> &iter)
{
  cout << data << " ";
}
template <typename T>
void dump(const vector<T> &data, vector<int> &iter)
{
  for (auto elem : data)
    dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>> &data, vector<int> &iter)
{
  for (auto elem : iter)
  {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++)
  {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T> &data, int dummy)
{
  for (int i = 0; i < data.size(); i++)
  {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T &data)
{ // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

const long long MOD = 1000000007;

void solve(long long N, long long K)
{
  LL minim = 0;
  LL maxim = 0;

  LL ans = 0;
  for (int i = 0; i <= N; i++)
  {
    minim += i;
    maxim += N - i;
    if (i + 1 < K)
      continue;
    ans += (maxim - minim + 1);
    ans %= MOD;
  }
  cout << ans << endl;
}

int main()
{
  cout << setprecision(10);
  long long N;
  scanf("%lld", &N);
  long long K;
  scanf("%lld", &K);
  solve(N, K);
  return 0;
}


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

struct edge{
    int to,cost;
};
bool operator> (const edge &edge1, const edge &edge2){
    return edge1.cost > edge2.cost;
};
struct node{
    int x,y,name;
};
bool compx (const node &node1, const node &node2){
    return node1.x < node2.x;
};
bool compy(const node &node1, const node &node2){
    return node1.y < node2.y;
}


int main(){
    int n;
    cin>>n;
    //(x,y)
    vector< node > city(n);
    for(int i=0;i<n;i++){
        cin>>city[i].x>>city[i].y;
        city[i].name = i;
    }
    //各ノードから出る辺を考える
    vector< vector<edge> > G(n); 
    //xでそーと
    sort(city.begin(),city.end(),compx);
    for(int i=0;i<n-1;i++){
        int dis = city[i+1].x-city[i].x;
        edge edge1,edge2;
        edge1.to = city[i+1].name;
        edge1.cost = dis;
        G[city[i].name].push_back(edge1);
        edge2.to = city[i].name;
        edge2.cost = dis;
        G[city[i+1].name].push_back(edge2);
    }
    //yでソート
    sort(city.begin(),city.end(),compy);
    for(int i=0;i<n-1;i++){
        int dis = city[i+1].y-city[i].y;
        edge edge1,edge2;
        edge1.to = city[i+1].name;
        edge1.cost = dis;
        G[city[i].name].push_back(edge1);
        edge2.to = city[i].name;
        edge2.cost = dis;
        G[city[i+1].name].push_back(edge2);
    }

    priority_queue<edge, vector<edge>, greater<edge> > pq; 
    vector<bool> used(n,false);
    used[0]=true;
    for(int i=0;i<G[0].size();i++){
        pq.push(G[0][i]);
    }
    int ans = 0;
    while(!pq.empty()){
        //一番最小の辺
        edge tmp = pq.top();
        pq.pop();
        int to = tmp.to;
        int cost = tmp.cost;
        if(used[to]) continue;
        used[to] = true;
        ans += cost;
        for(int i=0;i<G[to].size();i++){
            pq.push(G[to][i]);
        }
    }
    cout<<ans<<endl;
    return 0;

}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

map<ll, ll> mp;
void prime_factorization(ll x){
    bool flag = true;
    while(flag){
        ll sqx = sqrt(x)+1;
        for(ll j=2;j<sqx+1;j++){
            if(x%j==0){
                mp[j]++;
                x/=j;
                break;
            }
            if(j==sqx) flag = false;
        }
    }
    if(x!=1){
        mp[x]++;
    }
}

int main(){
	ll N;
	cin >> N;
	ll res = 0;
	for(int i=1;i<=N;i++){
		if(i%2==0) continue;
		mp.clear();
		prime_factorization(i);
		ll tmp = 1;
		for(map<ll, ll>::iterator itr=mp.begin();itr!=mp.end();itr++){
        	tmp *= (itr->second+1);
    	}
    	if(tmp==8) res++;
	}
	cout << res << endl;
    return 0;
}

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> s(m);
    vector<int> c(m);

    if (n == 1 && m == 0){
        cout << 0 << endl;
        return 0;
    }

    for (int i=0; i<m; i++){
        cin >> s[i] >> c[i];
    }

    for (int i=0; i<m; i++){
        for (int j=i; j<m; j++){
            if (s[i] == s[j] && c[i] != c[j]){
                cout << -1 << endl;
                return 0;
            }
        }
    }

    if (n == 1){
        if (c[0] == 0){
            cout << 0 << endl;
            return 0;
        }
    }

    for (int i=0; i<m; i++){
        if (s[i] == 1 && c[i] == 0){
            cout << -1 << endl;
            return 0;
        }
    }


    vector<int> ans(n);
    for (int i=0; i<n; i++){
        if (i == 0) ans[i] = 1;
        else ans[i] = 0;
    }
    for (int i=0; i<m; i++){
        ans[s[i]-1] = c[i];
    }
    for (int i=0; i<n; i++){
        cout << ans[i];
    }
    cout << endl;
    return 0;
}

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

//素数判定
bool isPrime(int num){
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false;
  double sqrtNum = sqrt(num);
  for (int i = 3; i <= sqrtNum; i += 2){
    if (num % i == 0) return false;
  }
  return true;
}

int main(){
  ll a;
  cin >> a;
  
  ll ans = 0;
  for(ll i = a; ; i++){
    if(isPrime(i)){
      ans = i;
      break;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  int a, b;
  cin >> a >> b;

  string ab = "";
  string ba = "";
  for (int i = 0; i < b; i++) {
    ab += a + '0';
  }
  for (int i = 0; i < a; i++) {
    ba += b + '0';
  }

  if (ab > ba) {
    cout << ba << ln;
  } else {
    cout << ab << ln;
  }

  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+3;
string s,p;
//vector<int>v;
//map<int,int>mp;
int a[105];
int main()
{
    ft
    ll t,i,j,n,m,l,r;
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
        cin>>l;
        for(j=0;j<l;j++)
        {
            cin>>r;
            a[r]=1;
        }
    }
    l=0;
    for(i=1;i<=n;i++)
    {
        if(a[i]==0)
        {
            l++;
        }
    }
    cout<<l<<"\n";
    return 0;
}



Measured memory_bytes: 3608
#include<iostream>
#include<vector>
using namespace std;
int ans[100010], n, g;
bool in[100010]={};
vector<pair<int, int>> G[100010];

void dfs(int k){
    ans[k]=g%2;
    in[k]=true;
    for(int i=0; i<G[k].size(); i++){
        if(!in[G[k][i].first]){
            g+=G[k][i].second%2;
            dfs(G[k][i].first);
            g-=G[k][i].second%2;
        }
    }
}

int main(){
    cin>>n;
    for(int i=0; i<n-1; i++){
        int u, v, w;
        cin>>u>>v>>w;
        u--;  v--;
        G[u].emplace_back(v, w);
        G[v].emplace_back(u, w);
    }
    g=0;
    dfs(0);
    for(int i=0; i<n; i++) cout<<ans[i]<<endl;
}


Measured memory_bytes: 8960
using System;
using System.Linq;

class B
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var a = new int[n]
			.Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray())
			.Select(x => new { l = x[0] - x[1], r = x[0] + x[1] })
			.OrderBy(x => x.l);

		var dp = Enumerable.Repeat(int.MaxValue, n + 1).ToArray();
		dp[0] = int.MinValue;
		foreach (var x in a)
		{
			var j = Last(0, n, i => dp[i] <= x.l) + 1;
			dp[j] = Math.Min(dp[j], x.r);
		}
		Console.WriteLine(Last(0, n, i => dp[i] < int.MaxValue));
	}

	static int Last(int l, int r, Func<int, bool> f)
	{
		int m;
		while (l < r) if (f(m = r - (r - l - 1) / 2)) l = m; else r = m - 1;
		return l;
	}
}


Measured memory_bytes: 24244