akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#ifdef _DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif
#define REP(i, m, n) for(int (i) = (int)(m); (i) < (int)(n); ++(i))
#define rep(i, n) REP(i, 0, n)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9 + 7;
const ll LINF = 1LL << 60;
template<class T, class U> inline bool chmax(T &a, const U &b) { if(a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if(a > b) { a = b; return true; } return false; }

int n, a[100000];
ll dp[100010];

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  cin >> n;
  rep(i,n) cin >> a[i];

  rep(i,100010) dp[i] = LINF;
  rep(i,n) {
    auto it = lower_bound(dp, dp+n, a[i]);
    *it = a[i];
  }
  int ans = 0;
  for(int i = n-1; i >= 0; i--) if(dp[i] != LINF) {
    ans = i+1;
    break;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 4392
n = int(input())
b = list(map(int,input().split()))

wa = 0

for i in range(n):
    if i == 0:
        wa += b[0]
    elif i == n-1:
        wa += b[n-2]
    else:
        wa += min(b[i-1],b[i])

print(wa)

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

typedef long long int ll;
int a[100][100];
void solved(){
	int n,m,x;cin>>n>>m>>x;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m + 1; j++){
			cin>>a[i][j];
		}
	}
	ll ans = 1e18;
	for(int i = 1; i < (1 << n); i++){
		vector<ll>ve(100);
		ll temp = 0;
		for(int j = 0; j < n; j++){
			if(i & (1 << j)){
				int v = j + 1;
				temp += a[v][1];
				for(int k = 2; k <= m + 1; k++){
					ve[k]+=a[v][k];
				}
			}
		}
		bool flag = true;
		for(int k = 2; k <= m + 1;k++){
			if(ve[k] < x){
				flag = false;break;
			}
		}
		if(flag){
			ans = min(ans,temp);
		}
	}
	if(ans == 1e18)
	cout<<"-1"<<endl;
	else cout<<ans<<endl;
}
int main(){
	solved();
	return 0;
} 

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

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using uint=unsigned int;
using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

ll readLL(){
	ll i;
	scanf("%lld",&i);
	return i;
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

int main(){
	int n=read();
	ll p=1,q=1;
	REP(i,n){
		ll t=read(),a=read();
		ll u1=((p-1)/t+1)*t,u2=((p-1)/t+1)*a;
		ll v1=((q-1)/a+1)*t,v2=((q-1)/a+1)*a;
		if(u1>v1){
			p=u1,q=u2;
		}else{
			p=v1,q=v2;
		}
	}
	cout<<p+q<<endl;
}


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

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

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976

int main()
{
    int a,b,c; cin >> a >> b >> c;
    int x,y; cin >> x >> y;
    int t = a * x + b * y;
    if(x < y){
        int s = x * 2 * c + (y-x) * b;
        int u = y * 2 * c;
        cout << min({s,t,u});
    }else{
        int s = y * 2 * c + (x-y) * a;
        int u = x * 2 * c;
        cout << min({s,t,u});
    }
}

Measured memory_bytes: 256
def solve(N, K, As):
    for i in range(N - K):
        if As[i] >= As[K + i]:
            print('No')
        else:
            print('Yes')


if __name__ == '__main__':
    # S = input()
    # N = int(input())
    N, K = map(int, input().split())
    As = [int(i) for i in input().split()]
    # Bs = [int(i) for i in input().split()]
    solve(N, K, As)

Measured memory_bytes: 31532
#include <bits/stdc++.h>
using namespace std;
 
bool solve() {
    int N;
    cin >> N;
    if(!N) return false;
 
    vector<int> A(N);
    int sum = 0;
    for(int &e : A) {
        cin >> e;
        sum += e;
    }
 
    int ans = 0;
    for(int i = 0; i < N; i++) if(N * A[i] <= sum) ans++;
    cout << ans << endl;
    return true;
}
 
int main() {
    while(solve());
    return 0;
}


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

int main(){
    int h, w;
    cin >> h >> w;
    string s;
    rep(i,h){
        rep(k,w){
            cin >> s;
            if(s=="snuke"){
                cout << (char)('A'+k) << i+1 << endl;
                break;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>
#include <ciso646>
#include <cassert>

using namespace std;

#define int long long
#define double long double

typedef pair<int, int> P;
typedef tuple<int, int, int> T;

template<class T> string tostr(T x) { stringstream o; o << x; return o.str(); }
template<class T> T sqr(T x) { return x*x; }
template<class T> T mypow(T x, int n) { T r = 1; while (n > 0) { if (n & 1)r = r*x; x = x*x; n >>= 1; }return r; }

int toint(string s) { int v; stringstream i(s); i >> v; return v; }
bool check(int x, int y, int w, int h) { return x >= 0 && y >= 0 && w > x && h > y; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

#define REP(i,a,b)	for(int (i) = (a);i < (b);(i)++)
#define rep(i,n)	REP(i,0,n)
#define PER(i,a,b)	for(int (i) = (a-1);i >= (b);(i)--)
#define per(i,n)	PER(i,n,0)
#define each(i,n)	for(auto &i : n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define dump(val) 	cerr << #val " = " << val << endl;
#define dum(val)	cerr << #val " = " << val;
#define FILL(a,v)	fill(a,a+sizeof(a)/sizeof(*a),v)

const int dx[8] = { +1,+0,-1,+0,+1,+1,-1,-1 };
const int dy[8] = { +0,-1,+0,+1,-1,+1,-1,+1 };
const int mod = 1e9 + 7;
const int INF = 1e17 + 9;

signed main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	
	string s;
	cin >> s;

	int win = 0; //win - lose
	int cnt = 0; //gc - pc

	each(c, s) {
		if (c == 'g') {
			cnt++;
		}
		else {
			win--; cnt++;
		}
	}

	per(i, s.size()) {
		auto c = s[i];
		if (cnt < 2)break;
		cnt -= 2;
		win++;
	}
	cout << win << endl;

	return 0; 
}

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

#define _GLIBCXX_DEBUG
#define rep(i, V) for (int i = 0; i < V; i++)
#define repr(i, V) for (int i = V-1; i >= 0; i--)
#define repval(i, a, V) for (int i = a; i < V ; i++)
#define all(x) x.begin(), x.end()
#define ld long double
#define eps 0.0000000001
#define mod 1000000007
#define inf 1e9
#define vec vector
#define each(i, mp) for(auto& i:mp)

int main(){
    int n,k;
    cin >> n >> k;

    vec<int> x(n), y(n);
    vec<int> xary, yary;

    rep(i, n){
        cin >> x[i] >> y[i];
        xary.push_back(x[i]);
        yary.push_back(y[i]);
    }

    sort(all(xary));
    sort(all(yary));

    ll ans = 1LL * (xary[n-1] - xary[0]) * (yary[n-1] - yary[0]);

    rep(xi, n)repval(xj, xi+1, n)rep(yi, n)repval(yj, yi+1, n){
        ll lx = xary[xi], rx = xary[xj];
        ll by = yary[yi], uy = yary[yj];
        int num = 0;
        rep(i, n){
            if(lx <= x[i] && x[i] <= rx && by <= y[i] && y[i] <= uy){
                num++;
            }
        }

        if (num >= k) ans = min(ans, 1LL * (rx-lx) * (uy-by));
    }

    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> o_tree;


void solve()
{
    string s,t;
    ll a,b;
    cin>>s>>t>>a>>b;
    string ss;
    cin>>ss;
    a-=(ss==s);
    b-=(ss==t);
    cout<<a<<" "<<b<<"\n";
}


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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

Measured memory_bytes: 3656
n = int(input())
stones = input()

redflag = False
whiteflag = False
# for i in range(n):
#   if(stones[i]=="R"):
#     redflag = true
#   else:
#     whiteflag = true

# if(not(redflag and whiteflag)):
#   print(0)

start = 0
end = n - 1
count = 0
while(True):
  while(start < n and stones[start]!="W"):
    start += 1
  while(end >= 0 and stones[end]!="R"):
    end -= 1
  if(start >= end):
    break
  start += 1
  end -= 1
  count += 1

print(count)

  


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

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

const int MN = 100010;

int N;
pii S[MN];
priority_queue<pii> pq1, pq2;
int chk[MN];

int main() {
    scanf("%d", &N);

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

    for(int i = 0; i < N; i++) {
        pq1.push({ S[i].first, i });
        pq2.push({ -S[i].second, i });
    }

    ll ans = 0;
    pii t = pq1.top(); pq1.pop();
    int pos = t.first;
    chk[t.second] = 1;

    for(int i = 0; i < N; i++) {
        if(i % 2) {
            while(!pq1.empty() && chk[pq1.top().second]) pq1.pop();
            pii t = pq1.top(); pq1.pop();
            if(t.first <= pos) break;
            int nxt = t.first;
            ans += abs(pos - nxt);
            pos = nxt;
            chk[t.second] = 1;
        }
        else {
            while(!pq2.empty() && chk[pq2.top().second]) pq2.pop();
            pii t = pq2.top(); pq2.pop();
            if(-t.first >= pos) break;
            int nxt = -t.first;
            ans += abs(pos - nxt);
            pos = nxt;
            chk[t.second] = 1;
        }
    }

    ans += abs(t.first - pos);
    printf("%lld", ans);
}


Measured memory_bytes: 3180
/********************************************************
  **░██████╗██╗░░░░░░█████╗░██╗░░░██╗██╗░█████╗░░██████╗░**
  **██╔════╝██║░░░░░██╔══██╗██║░░░██║██║██╔══██╗██╔════╝░**
  **╚█████╗░██║░░░░░███████║╚██╗░██╔╝██║██║░░╚═╝██║░░██╗░**
  **░╚═══██╗██║░░░░░██╔══██║░╚████╔╝░██║██║░░██╗██║░░╚██╗**
  **██████╔╝███████╗██║░░██║░░╚██╔╝░░██║╚█████╔╝╚██████╔╝**
  **╚═════╝░╚══════╝╚═╝░░╚═╝░░░╚═╝░░░╚═╝░╚════╝░░╚═════╝░**
  *********************************************************/
 
#include <bits/stdc++.h>
using namespace std;
 
 
#define ll                          long long
#define ld                          long double
 
#define forn(i,n)                   for(int i=0;i<n;++i)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend()
#define isSubstring(s1,s2)          s1.find(s2) != std::string::npos
	
#define pb                          push_back
#define pf                          push_front
#define mp                          make_pair
#define fr                          first
#define sc                          second
 
#define vpi                         vector<pair<int,int>>
#define vi                          vector<int>
#define sz(a)                       (int)a.size()
 
#define   endl                       "\n"
#define     nl                       cout<<"\n";
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
#define  MN                           INT_MIN
#define  MX                           INT_MAX
bool isPrime(ll n){if(n<2)return false;for(ll x = 2;x*x <=n;x++){if(n%x == 0)return false;}return true;}
bool isPerfectSquare(long double x){long double sr=sqrt(x);return((sr-floor(sr))==0);}
int gcd(int a, int b){if(a==0)return b;if(b==0) return a;if(a==b)return a;if(a>b)return gcd(a-b,b);return gcd(a,b-a);}
 
int32_t main()
{
	int a,b;
	cin >> a >> b;
	if(a<6){
		cout << 0 << endl;
	}else if(a < 13)
	{
		cout << b / 2 << endl;
	}else{
		cout << b << endl;
	}
}

Measured memory_bytes: 3668
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	while(1){
		int x,y;
		cin >> x >> y;
		if(x==0 && y==0)break;
		if(x>y)swap(x,y);
		cout << x << " " << y << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstring>
#include <algorithm>
#include <functional>
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
 
int main () {
  int n, k;
  cin >> n >> k;
  int x, sum;
  sum = 0;
  for (int i = 0; i < n; i++){
    cin >> x;
    if (x < k-x){
      sum += 2*x;
    }else{
      sum += 2*(k-x);
    }
  }
  cout << sum << endl;
  return 0;
}

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

int main() {
    int N,M;
    cin >> N >> M;
    vector<int> p(N,0);
    vector<pair<P,int>> h(M);
    vector<string> r(M);

    rep(i,M) {
        cin >> h.at(i).first.second >> h.at(i).first.first;
        h.at(i).second = i;
    }
    sort(h.begin(), h.end());

    rep(i,M) {
        string x,y,t="";
        x = to_string(h.at(i).first.second);
        y = to_string(++p.at(h.at(i).first.second-1));

        rep(j,6-x.size())
            t += "0";
        t += x;
        rep(j,6-y.size())
            t += "0";
        t += y;

        r.at(h.at(i).second) = t;
    }

    rep(i,M)
        cout << r.at(i) << endl;
}

Measured memory_bytes: 9728
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main():
    N = II()
    A = LI()

    A.sort()
    from bisect import bisect
    slice_ = bisect(A, 0)
    from collections import deque
    minus = deque(A[:slice_])
    plus = deque(A[slice_:])
    # print(minus, plus)

    if minus and plus:
        first_plus = plus.popleft()
        first_minus = minus.popleft()
    elif minus and not plus:
        first_plus = minus.pop()  # must be the max of minuses
        first_minus = minus.popleft()
    elif plus and not minus:
        first_minus = plus.popleft()  # must be the min of pluses
        first_plus = plus.popleft()

    # first_plus - (first_minus - plus - plus - ...) - minus - minus - ...
    tmp = first_minus
    ans_li = []
    while len(plus) > 0:
        p = plus.popleft()
        ans_li.append((tmp, p))
        tmp = tmp - p
    ans_li.append((first_plus, tmp))
    tmp = first_plus - tmp
    while len(minus) > 0:
        m = minus.popleft()
        ans_li.append((tmp, m))
        tmp = tmp - m
    print(tmp)
    for i in ans_li: print('{} {}'.format(*i))


main()

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

using namespace std;

const int mod = 998244353;

struct mint {
  int n;
  mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { return (a.n += b.n) >= mod ? a.n - mod : a.n; }
mint operator-(mint a, mint b) { return (a.n -= b.n) < 0 ? a.n + mod : a.n; }
mint operator*(mint a, mint b) { return 1LL * a.n * b.n % mod; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }

mint fact[5050];
mint inv[5050];
mint ifact[5050];
mint dp[5050][5050];

mint C(int n, int r) {
  if (n < 0 || r < 0 || n < r) return 0;
  return fact[n] * ifact[r] * ifact[n - r];
}

mint H(int n, int r) {
  if (n == 0 && r == 0) return 1;
  return C(r + n - 1, r);
}

int main() {
  int N, K;
  cin >> K >> N;
  inv[1] = 1;
  for (int i = 2; i < 5050; i++) {
    inv[i] = (mod - mod / i) * inv[mod % i];
  }
  fact[0] = 1;
  ifact[0] = 1;
  for (int i = 1; i < 5050; i++) {
    fact[i] = i * fact[i - 1];
    ifact[i] = inv[i] * ifact[i - 1];
  }
  dp[0][0] = 1;
  for (int i = 0; i < 5000; i++) {
    for (int j = 0; j < 5000; j++) {
      dp[i + 1][j] += dp[i][j];
      dp[i + 1][j + 1] -= dp[i][j];
      dp[i + 1][j + 1] += dp[i][j] * 2;
    }
    for (int j = 0; j < 5000; j++) {
      dp[i + 1][j + 1] += dp[i + 1][j];
    }
  }
  for (int i = 2; i <= 2 * K; i++) {
    mint ans;
    int l = max(1, i - K);
    int r = min(K + 1, i);
    int x = max(0, r - l);
    int y = K - x;
    for (int j = 0; j <= N; j++) {
      if (x % 2 == 1) {
        ans += H(y, N - j) * dp[(x - 1) / 2][j];
        ans += H(y, N - 1 - j) * dp[(x - 1) / 2][j];
      } else {
        ans += H(y, N - j) * dp[x / 2][j];
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 99968
n=int(input())
a=[int(x) for x in input().split()]

t1=[0 for i in range(200010)]
t2=[0 for i in range(200010)]

for i in range(len(a)):
  if i-a[i]>=0:
    t1[i-a[i]]+=1
  if a[i]+i<200010:
    t2[a[i]+i]+=1
ans=0
for i in range(200010):
  ans += t1[i]*t2[i]
print(ans)

Measured memory_bytes: 32320
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int lim = 2e2+5;
const int mod = 1e9+7;

int graph[lim][lim],vis[lim],f=1,n;
void dfs(int x,int t) {
	//cout<<x<<' '<<t<<' '<<vis[x]<<endl;
	if(vis[x]!=0) {
		f &= (vis[x]==t);
		return;
	}
	vis[x] = t;
	for(int i=1;i<=n;i++)
		if(graph[i][x]==1)
			dfs(i,t==1?2:1);
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    cin>>n;
    for(int i=1;i<=n;i++)
    	for(int j=1;j<=n;j++) {
    		char x;
    		cin>>x;
    		if(x=='0')
    			graph[i][j] = 1e5;
    		else
    			graph[i][j] = 1;
    		graph[i][i] = 0;
    	}
    dfs(1,1);
    if(f==0)
   		cout<<-1;
   	else {
   		for(int k=1;k<=n;k++)
   			for(int i=1;i<=n;i++)
   				for(int j=1;j<=n;j++)
   					if(graph[i][j]>graph[i][k]+graph[k][j])
   						graph[i][j] = graph[i][k]+graph[k][j];

   		int k = 0;
   		for(int i=1;i<=n;i++)
   			for(int j=1;j<=n;j++)
   				if(graph[i][j]!=1e5)
   					k = max(k,graph[i][j]);
   		cout<<k+1;
   	}
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using Graph = vector<vector<bool>>;
const int MOD = 1e9 + 7;

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

    string s;
    int x, y;
    cin >> s >> x >> y;
    if (s.back() != 'T')
        s.push_back('T');

    bool v = false, ini = false;
    int cnt = 0;
    vector<bitset<16000>> dp(2);
    dp[1][8000] = true;
    for (int i = 0; i < s.length(); ++i) {
        if (s[i] == 'T') {
            if (!ini) {
                dp[v][8000 + cnt] = true;
                ini = true;
            } else
                dp[v] = (dp[v] >> cnt) | (dp[v] << cnt);
            v ^= 1;
            cnt = 0;
            continue;
        }
        cnt++;
    }

    cout << (dp[0][8000 + x] & dp[1][8000 + y] ? "Yes" : "No") << endl;
    return 0;
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

struct edge {
	int to, cost;
	edge(int t,int c):to(t),cost(c) {}
};

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

ll mypow(ll x,ll n,ll m) {	//xのn乗をmで割った余り
	if(n==0) return 1;
	if(n%2==0) return mypow(x*x%m,n/2,m);
	else return x*mypow(x,n-1,m)%m;
}

//-----------------------------------------------------------------------------

int sx,sy,gx,gy,n;
vector<P> v;
const int inf=1.1e8;

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

	cin>>sx>>sy>>gx>>gy>>n;
	int t=0;
	if(sx>gx) swap(sx,gx),swap(sy,gy);
	if(sy>gy){ t=1,sy=-sy;gy=-gy; }
	REP(i,n) {
		int x,y;cin>>x>>y;
		if(t) y=-y;
		if(x<sx||x>gx||y<sy||y>gy) continue;
		v.pb(P(x,y));
	}
	sort(ALL(v));

	int sz=v.size();
	int dp[sz+1];
	fill(dp,dp+sz+1,inf);
	REP(i,sz) {
		*lower_bound(dp,dp+sz+1,v[i].se)=v[i].se;
	}
	int num=lower_bound(dp,dp+sz+1,inf)-dp;
	double ans=((gx-sx)+(gy-sy))*100.-num*20.+num*20*PI/4;
	if(num==(gx-sx)+1||num==(gy-sy)+1) ans+=20*PI/4;
	printf("%.15lf\n",ans);

	return 0;
}


Measured memory_bytes: 2800
N=int(input())
y,f=[],[]
for i in range(1,int(N**0.5+1)):
	if N%i==0:
		y.append(i-1)
		if not i**2==N:
			y.append((N//i)-1)
del y[0]
for i in y:
	if (N//i)==(N%i):
		f.append(i)
print(sum(f))

Measured memory_bytes: 3188
#define M 1000000
n[M];main(i,j){n[0]=0;n[1]=-1;for(i=2;i<M;i++)if(!n[i])for(j=i*2;j<M;j+=i)n[j]=-1;for(i=1;i<M;i++)n[i]+=n[i-1]+1;for(;~scanf("%d",&i);printf("%d\n",n[i]));exit(0);}

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

int x,y,i,j;
bool ans;

int main(){
	cin >> x >> y;
	ans = false;
	for(i=0; i<=100; i++){
		for(j=0; j<=100; j++){
			if((i+j==x) && (2*i+4*j == y)){
				cout << "Yes" << endl;
				ans = true;
				break;
			}
		}
		if(ans){
			break;
		}
	}
	if(!ans){
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;                                                            
#define pb push_back                                                            
#define mp make_pair                                                                                                                                
#define sqr(a) ((a) * (a))                                                      
#define io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);   
#define co() cout.precision(10);                                                
#define F for(li i=0;i<n;i++)
#define fo(i,a,n) for(i=a;i<n;i++)
#define ne cout<<"\n"; 
#define test int t;cin>>t;while(t--)
//#define oj #ifndef ONLINE_JUDGE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif

typedef long long li;
typedef long double ld;

const li mod = 1000000007;
li divisibilityCheck(li arr[], li n) 
{ 
    unordered_set<int> s; 
    li max_ele = INT_MIN,i,j; 
    for (i = 0; i < n; i++) { 
        s.insert(arr[i]);
        max_ele = max(max_ele, arr[i]); 
    } 
    unordered_set<li> res; 
    for ( i = 0; i < n; i++) { 
        if (arr[i] != 0) {  
            for (j = arr[i] * 2; j <= max_ele; j += arr[i]) { 
                if (s.find(j) != s.end()) 
                    res.insert(j); 
            } 
        } 
    } 
    unordered_map<li,li> mp; 
    for ( i = 0; i < n; i++) 
        mp[arr[i]]++; 
  
    unordered_map<li,li>::iterator it; 
    vector<li> ans; 
    for (it = mp.begin(); it != mp.end(); it++) { 
        if (it->second >= 2) { 
            if (res.find(it->first) == res.end()) { 
                li val = it->second; 
                while (val--) 
                    ans.push_back(it->first); 
            } 
        } 
        if (res.find(it->first) != res.end()) { 
            li val = it->second; 
            while (val--) 
                ans.push_back(it->first); 
        } 
    } 
    return ans.size();
} 
int main()
{
	li n,x,i,j,c=1;
	cin>>n;
	set<li>s;
	li a[n];
	F {
	cin>>a[i];
	s.insert(a[i]);
	}
	
	x=divisibilityCheck(a,n);
	cout<<n-x;
}

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

int main() {
  int x, a; cin >> x >> a;
  if (x < a)
  {
    cout << 0 << endl;
  } else {
    cout << 10 << endl;
  }
  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;
const ll mod=1e9+7;


int S,T;
string s,t;

vi f(){
	int I=0;
	vi a;
	for(int i=0;i<S;i++) if(I<T&&s[i]==t[I]){
		a.push_back(i);
		I++;
	}
	for(int i=a.size();i<T;i++) a.push_back(S);
	return a;
}

int main(){
	cin>>s>>t;
	S=s.size();
	T=t.size();
	vi a=f();
	reverse(s.begin(),s.end());
	reverse(t.begin(),t.end());
	vi b=f();
	bool flag=1;
	for(int i=0;i<T;i++) if(a[i]+b[T-i-1]!=S-1) flag=0;
	if(flag) cout<<"yes"<<endl;
	else cout<<"no"<<endl;
}

Measured memory_bytes: 8984
N,M=map(int,input().split())
count=0
if N>=1 and M>=2:
    a=M//2
    if N>=a:
        M=M-2*a
        answer=a
    else:
        M=M-2*N
        answer=N
else:
    answer=0
if M>=4:
    kotae=M//4
else:
    kotae=0
print(answer+kotae)


Measured memory_bytes: 2940
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
#define ms(a,b) memset(a,b,sizeof(a))

int main()
{
    //ios::sync_with_stdio(0);cin.tie(0);
    int a,b,c;
    while(~scanf("%d%d%d",&a,&b,&c)){
        printf("%d\n",a^b^c);
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
typedef pair<int,int> pi;
map<int,int>m;
int main(){
	int n;
	cin>>n;
	map<int,int>::iterator it;
	while(n--){
		int a;
		cin>>a;
		it = m.find(a);
		if(it==m.end()) m.insert(pi(a,1));
		else it->second+=1;
	}
	int ret = 0;
	for(it = m.begin(); it!=m.end(); it++){
		if(it->first<=it->second) ret+=(it->second-it->first);
		else if(it->first>it->second) ret+=it->second;
	}
	cout<<ret;
}

Measured memory_bytes: 7664
#include <iostream>

using namespace std;
using ll = long long;

const ll INF = 1LL << 50;

ll sum[410], dp[410][410];
bool visited[410][410];

ll rec(int l, int r) {
    if (visited[l][r]) return dp[l][r];
    if (l == r) return 0;
    visited[l][r] = true;

    dp[l][r] = INF;
    for (int i = l; i < r; ++i) {
        dp[l][r] = min(dp[l][r], rec(l, i) + rec(i + 1, r));
    }

    dp[l][r] += sum[r] - sum[l - 1];
    return dp[l][r];
}

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

    for (int i = 1; i <= N; ++i) {
        ll a;
        cin >> a;
        sum[i] = sum[i - 1] + a;
    }

    cout << rec(1, N) << endl;
    return 0;
}


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

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

  int count = 0;
  for (int i = 0; i < str.size(); i++) {
    if (str.at(i) == str.at(0)) {
      count++;
    }
  }
  for (int i = 0; i < str.size(); i++) {
    if (str.at(i) != str.at(0)) {
      count--;
    }
  }
  for (int i = 0; i < str.size(); i++) {
    if (str.at(i) != str.at(1)) {
      count++;
    }
  }
    for (int i = 0; i < str.size(); i++) {
    if (str.at(i) != str.at(2)) {
      count++;
    }
  }
    for (int i = 0; i < str.size(); i++) {
    if (str.at(i) != str.at(3)) {
      count++;
    }
  }
    if (count == 6) {
      cout << "Yes" << endl;
    }
  else {
    cout << "No" << endl;
}
}

          

Measured memory_bytes: 256
// --------------
// Tejas Pandey  |
// 01 - 09 - 19  |
// ABC #139      |
// --------------

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

#define mod 1000000007
#define vi vector<int>
typedef long long int ll;

int main (void)
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
	//cin >> t;
	while(t--)
	{
		//cout << "Case #" << c-t << ": ";
		int a,b;
		cin >> a >> b;
		int ans = 0,cur = 1;
		while(cur < b){
			ans++;
			cur += (a-1);
		}
		cout << ans << "\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		int out=0,runner=0,point=0;
		while(out!=3){
			char str[8]={};
			scanf("%s",str);
			if(str[0]==72){
				if(str[1]==73){
					runner++;
					if(runner==4){
						runner--;
						point++;
					}
				}
				else {
					point=point+runner+1;
					runner=0;
				}
			}
			else {
				out++;
			}
		}
		printf("%d\n",point);
	}
return 0;
}

Measured memory_bytes: 592
import java.util.Arrays;

public class Main {
  private static void solve() {
    int[] a = {ni(), ni(), ni()};
    Arrays.sort(a);
    int k = ni();
    for (int i = 0; i < k; i ++) {
      a[2] *= 2;
    }
    System.out.println(a[0] + a[1] + a[2]);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}




Measured memory_bytes: 21332
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;

#define LEN(x) (int)x.size()
#define ALL(x) x.begin(), x.end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
using vpii = vector<pii>;

template<typename T, typename M = __gnu_pbds::null_type>
using ordered_set = __gnu_pbds::tree<T, M, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

template<typename T>
const T INF = (is_same<T, int>::value ? 1e9 : 1e18);
const int MOD = 1e9 + 7;
const double EPS = 1e-9;

inline int fcmp(double x, double y)
{ return (x < y + EPS ? (x < y - EPS ? -1 : 0) : 1);}

const int N = 1e5 + 10;
vi adj[N];
int p[N];
queue<int> q;

int main()
{
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    
    int n, m;
    cin >> n >> m;

    while(m--)
    {
        int a, b;
        cin >> a >> b;
        adj[a].emplace_back(b);
        adj[b].emplace_back(a);
    }

    q.emplace(1);
    p[1] = 1;

    while(!empty(q))
    {
        int v = q.front();
        q.pop();

        for(int u : adj[v])
             if(!p[u])
                p[u] = v, q.emplace(u);
    }

    cout << "Yes" << endl;
    for(int i = 2; i <= n; i++)
        cout << p[i] << endl;

    return 0;
}

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

    if(n%1000==0)
    {
        cout<<0<<endl;
    }
    else
    {
        int x=n/1000;
        x++;
        int temp=x*1000;

        cout<<temp-n<<endl;
    }


    return 0;
   
}


Measured memory_bytes: 3644
#include<stdio.h>

int main()
{
	char a[201]={'x'},b[201]={'x'};
	int i,t,p,n,m;
	
	for(;a[0]!='-';){
		
		scanf("%s",a);
		
		if(a[0]!='-'){
			
			scanf("%d",&n);//n?????\??????????????°
			
			for(i=0;a[i]!='\0';i++){//i???????????°
				b[i]='0';
			}
			for(t=0;t<n;t++){
				
				scanf("%d",&m);//m?????\??????????????°
				
				for(p=0;p<m;p++){
					
					b[i-m+p]=a[p];
				}
				//printf("%s %s\n",a,b);
				for(p=0;p<i-m;p++){
					
					b[p]=a[m+p];
				}
				//printf("%s %s\n",a,b);
				for(p=0;p<i;p++){
					
					a[p]=b[p];
				}
				//printf("%s %s\n",a,b);
			}
			for(p=0;p<i;p++){
				
				printf("%c",a[p]);
			}
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 2604
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;


long long int n,a,b,c,d;
int main() {
	string s,t;
	cout << fixed << setprecision(18);
	cin>>n;
	while(n!=0){
		cin>>a>>b>>c>>d;
		long long int x,maxcoin=1000;
		long long int res[5];
		for(int i=0;i<=a;i++){
			for(int j=0;j<=b;j++){
				for(int k=0;k<=c;k++){
					for(int l=0;l<=d;l++){
						x=i*10+j*50+k*100+l*500-n;
						if(x<0){continue;}
						if(l!=0&&x/500>=1){continue;}
						if(k!=0&&x/100%5>=1){continue;}
						if(j!=0&&x/50%2>=1){continue;}
						if(i!=0&&x/10%5>=1){continue;}
						if(maxcoin>=a+b+c+d-i-j-k-l+x/500+x/100%5+x/50%2+x/10%5){
							res[0]=i;
							res[1]=j;
							res[2]=k;
							res[3]=l;
							maxcoin=a+b+c+d-i-j-k-l+x/500+x/100%5+x/50%2+x/10%5;
						}
					}
				}
			}
		}
		long long int output[5]={10,50,100,500};
		for(int i=0;i<4;i++){
			if(res[i]!=0){
				cout<<output[i]<<" "<<res[i]<<endl;
			}
		}
		
		cin>>n;
		if(n!=0){cout<<endl;}
	}
	

} 


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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(b<a){a=b;return true;}return false;}

const int MAX=510000;
long long fac[MAX],finv[MAX],inv[MAX];
void COMinit(){
    fac[0]=fac[1]=1;finv[0]=finv[1]=1;inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%mod;
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}
long long COM(int n,int k){
    if(n<k) return 0;
    if(n<0 or k<0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
ll fact_mod(ll n) {
    ll ret=1; 
    for(ll i=2;i<=n;i++) ret=ret*(i%mod)%mod;
    return ret;
} 
ll pow_mod(ll x, ll n){
    if(n==0) return 1;
    ll ret=pow_mod((x*x) % mod, n/2);
    if(n&1) ret=(ret*x)%mod;
    return ret;
}
//O(r)
ll combination_mod(ll n, ll r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    ll a=1;
    for(ll i=0;i<r;i++) a=a*((n-i)%mod)%mod;
    ll b=pow_mod(fact_mod(r), mod-2);
    return (a%mod)*(b%mod)%mod;
}
ll inv_mod(ll n){
    return pow_mod(n,mod-2);
}



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    ll n,k;cin>>n>>k;
    ll l=0,r=n;
    ll ans=0;
    if(k==1) ans+=r-l+1;
    for(int i=1;i<=n;i++){
       l+=i;r+=n-i;
       if(i+1>=k){
           ans+=r-l+1;
           ans%=mod;
       }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3672
//PseudoName

	#pragma GCC optimize("O3")
	#include <bits/stdc++.h>
	#include <ext/pb_ds/assoc_container.hpp>
	#include <ext/pb_ds/tree_policy.hpp>
	using namespace std;
	using namespace __gnu_pbds;
	template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


	#define FOR(i,n) for(i=0;i<n;i++)
	#define FOR1(i,n) for(i=1;i<=n;i++)
	#define FOR2(I, A, B) for (int I = (A); I <= (B); ++I)
	#define pb push_back
	#define unique_sort(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
	#define print(v) for(auto it:v)cout<<it<<" ";cout<<endl
	#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
	#define endl "\n"
	#define min3(a,b,c) min(a,min(b,c))
	#define forr(n) for(int i=0;i<n;i++)
	#define frr(n) for(int i=1;i<=n;i++)
	#define rep(i,a,b) for(int i=a;i<=b;i++)



	typedef long long ll;
	typedef long li;
	typedef vector<int> vi;
	typedef vector<ll> vli;
	typedef vector<vi> vvi;
	typedef vector<vli> vvli;
	typedef pair<int,int> pi;
	typedef pair<ll,ll> pli;
	typedef vector<pi> vpi;
	typedef vector<pli> vpli;



	//const ll MOD=1e9+7;

	/*
	ll fast_exp(ll base, ll exp) {
	    ll res=1;
	    while(exp>0) {
	       if(exp%2==1) res=(res*base)%MOD;
	       base=(base*base)%MOD;
	       exp/=2;
	    }
	    return res%MOD;
	}
	ll imod(ll a)
	{
		return fast_exp(a, MOD-2);
	}
	*/

	const double PI=3.14159;

	int main() {
	    fast();

	    double r;
       
	    cin>>r;
	    cout<<2*PI*r<<endl;



	}


Measured memory_bytes: 3800
#include "bits/stdc++.h"
using namespace std;

//33
typedef long long ll;

double power(double a , ll b) {
	double ans = 1;
	while (b) {
		if (b & 1) {
			ans = ans  * a;
		}
		a = a * a;
		b  /= 2;
	}
	return ans;
}

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> v(n + 1);
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
	}
	v[n] = k;
	sort(v.begin(),v.end());
	vector<int> ans(n);
	for (int i = 1; i <= n; ++i) {
		ans[i - 1] = v[i] - v[i - 1];
	}
	int g = 0;
	for (int i = 0; i < n; ++i) {
		g = __gcd(ans[i],g);
	}
	cout << g;
}


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

int main() {
  int n;cin>>n;
  ll mod=1e9+7;
  ll ans=1;
  for(int i=1;i<=n;i++){
    ans=i*ans%mod;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3588
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    a = II()

    print(a + a**2 + a**3)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 9156
var obj = init();
Main();
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");}
function init(){
  var inputFile = myin();
  var returnObj = {
    "list" : inputFile, "index" : 0, "max" : inputFile.length,
    "hasNext" : function(){return (this.index < this.max);},
    "next" : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var A = nextInt();
  var B = nextInt();
  var C = nextInt();
  var list = [[0,0,0],[0,0,0],[0,0,0]];
  list[0][0] = A;
  list[0][1] = B;
  list[1][1] = C;
  for(var i = 0; i <= 100; i++){
  	var x = i;
  	var sum = A + B + x;
  	list[0][2] = x;
  	list[2][0] = A + B - C;
  	list[1][0] = sum - A - list[2][0];
  	list[2][2] = sum - A - C;
  	list[2][1] = A + B - (B + C) + x;
  	list[1][2] = sum - x - list[2][2];
    
    if(list[0][0] + list[0][1] + list[0][2] == sum && 
      list[1][0] + list[1][1] + list[1][2] == sum && 
      list[2][0] + list[2][1] + list[2][2] == sum && 
      list[0][0] + list[1][0] + list[2][0] == sum && 
      list[0][1] + list[1][1] + list[2][1] == sum && 
      list[0][2] + list[1][2] + list[2][2] == sum && 
      list[0][0] + list[1][1] + list[2][2] == sum && 
      list[0][2] + list[1][1] + list[2][0] == sum){
      myout(myconv(list[0],8));
      myout(myconv(list[1],8));
      myout(myconv(list[2],8));
      break;
    }
  }
}

Measured memory_bytes: 9420
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N, M;
string S;
vector<int> G[400010];
bool came[400010];
bool finish[400010];
bool flag;

void dfs(int v){
    came[v] = true;
    for(auto u : G[v]){
        if(came[u]){
            if(!finish[u]) flag = true;
        }else{
            dfs(u);
        }
    }
    finish[v] = true;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> M >> S;
    for(int i = 0; i < M; ++i){
        int a, b;
        cin >> a >> b;
        a--, b--;
        if(S[a] == S[b]){
            G[N + a].push_back(b);
            G[N + b].push_back(a);
        }else{
            G[a].push_back(N + b);
            G[b].push_back(N + a);
        }
    }
    for(int i = 0; i < 2 * N; ++i){
        if(!finish[i]) dfs(i);
    }
    cout << (flag ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 24400
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed power(int x, int n)
{
 if(n==0)
  return 1;
 else if(n%2==0)
  return pow((x*x),n/2);
 else
  return (x*pow((x*x),n/2));
}

signed main()
{
 int n,k;
 cin>>n>>k;
 cout<<k*power(k-1,n-1);
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<string>
#define mod 1000000007
using ll = long long;
using namespace std; 

int main(){
    ll n; cin >> n;
    string A;
    ll count=0;
    ll ans=0;
    for (int i=0;i<n;i++){
        char a; cin >> a;
        A+=a;
        if (a=='R') count++;
    }
    for (int i=0;i<count;i++){
        if (A[i]=='W') ans++;
    }
    cout << ans << "\n";
}



Measured memory_bytes: 3756
# coding: utf-8
#a, b = map(int, raw_input().split())

n = input()
ss = []
for i in xrange(n):
    s = input()
    ss.append(s)
    
c = sum(ss)
if c % 10 == 0:
    t = True
    for s in ss:
        if s % 10 != 0:
            t = False
    if t:
        print 0
        exit()
    ss = sorted(ss)
    for s in ss:
        if s % 10 == 0:
            continue
        c -= s
        if c % 10 != 0:
            break
print c

Measured memory_bytes: 2568
import sys
def input():
	return sys.stdin.readline()[:-1]
n = int(input())
s = [input() for _ in range(n)]
parity = [-1 for _ in range(n)]

def dfs(x):
	for i in range(n):
		if s[x][i] == "1":
			if parity[i] == parity[x]:
				print(-1)
				sys.exit()
			elif parity[i] == -1:
				parity[i] = parity[x]^1
				dfs(i)
	return

parity[0] = 0
dfs(0)

dist = [[10**30 if s[i][j] == "0" else 1 for j in range(n)] for i in range(n)]
for i in range(n):
	dist[i][i] = 0

for k in range(n):
	for i in range(n):
		for j in range(n):
			dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])

#print(*dist, sep="\n")
diam = 0
for i in range(n):
	for j in range(n):
		if dist[i][j] < 10**30:
			diam = max(diam, dist[i][j])

print(diam+1)

Measured memory_bytes: 59996
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fr(i,j,n)   for(int i=j;i<(n);++i)
#define bk(i,j,n)   for(int i=j;i>n;--i)
#define mset(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define mod 1000000007
#define inf 1e18
#define iosbase ios_base::sync_with_stdio(false); cin.tie(NULL);
#define bye return

int main()
{
    ll h,a,c=0;
    cin>>h>>a;

    while(h>0)
    {
        h=h-a;
        c++;
    }

    cout<<c<<endl;
    bye 0;

}

Measured memory_bytes: 256
a=input()
a,b=a.split(" ")
a=int(a)
b=int(b)
c=input().split(" ")
d=0
for i in range(1,b):
  d=max(int(c[i])-int(c[i-1]),d)
d=max(a-int(c[-1])+int(c[0]),d)
print(a-d)


Measured memory_bytes: 18356
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <stdio.h>

using namespace std;
int main() {
	int N, M;

	cin >> N >> M;

	vector<pair< pair< int, int>, int > > contories;

	for (int i = 0; i < M; i++) {
		int p;
		int y;

		cin >> p >> y;
		auto country = make_pair(make_pair(p , y) , i);
		contories.push_back(country);

	}


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

	vector<int> result_p(M ,0);
	vector<int> result_num(M, 0);

	int num_in_p = 1;
	int cur_p = -1;
	int index = 0;
	for (auto country : contories) {
		auto  p = country.first.first;
		if (cur_p != p) {
			num_in_p = 1;
			cur_p = p;
		}
		int index = country.second;
		result_p[index] = cur_p;
		result_num[index] = num_in_p;
		num_in_p++;
	}


	for (int i = 0; i < M; i++) {
		printf("%06d%06d\n",result_p[i], result_num[i]);


	}

	return 0;
}

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

typedef pair<long long, long long> ii;


long long mod = 1000000007;
long long n, m, k;
int main(){
	//freopen("i.txt","r",stdin);
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> n;
	long long arr[n];
	long long s = 0;
	for(int i = 0;i < n;i++){
		cin >> arr[i];
		s += arr[i];
	}
	
	
	long long ans = 1023123213213213123;
	long long acc = 0;
	for(int i = 0;i < n;i++){
		acc += arr[i];
		ans  = min(ans, abs(acc-(s-acc)));
	}
	
	cout << ans;
	
	
}


Measured memory_bytes: 1792