akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define MOD  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
#define ps push_back
#define all(x) x.begin(),x.end()
double pi = 3.141592653589793;
using namespace std;
//ここから始めよう
int n;
vector<int>v[114514];
int dp[111111][2];
void dfs(int i,int par){
    int &b=dp[i][0],&w=dp[i][1];
    if(~b)return;
    b=1;w=1;
    for(auto e:v[i]){
        if(e==par)continue;
        dfs(e,i);
        (b*=dp[e][1])%=mod;
        (w*=(dp[e][1]+dp[e][0]))%=mod;
    }
}
signed main(){
    cin>>n;
    rep(i,0,n-1){
        int a,b;cin>>a>>b;
        a--;b--;
        v[a].ps(b);v[b].ps(a);
    }
    rep(i,0,n)rep(j,0,2)dp[i][j]=-1;
    dfs(0,-1);
    cout<<(dp[0][0]+dp[0][1])%mod<<endl;
    return 0;
}

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

#define int long long 

using namespace std;

set<int> pfact(int a){
    set<int> ret;
    //cout<<1<<endl;
    for(int i=2; i*i<=a; i++){
        //cout<<i<<endl;
        if(a%i==0)ret.insert(i);
        while(a%i==0) a/=i;
    }
    //cout<<2<<endl;
    if(a!=1){
        ret.insert(a);
    }
    return ret;
}

void solve(){
    int a,b;
    int cnt=1;
    cin>>a>>b;
    //cout<<"ho"<<endl;
    auto A=pfact(a);
    auto B=pfact(b);
    //cout<<"hei"<<endl;
    for(auto it=A.begin(); it!=A.end(); it++){
        if(B.find(*it)!=B.end()) cnt++;
        //cout<<*it<<endl;
    }
    cout<<cnt<<endl;
}

signed main(){
    //while(1)
    solve();
}

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

int main() {
    string s;
    cin >> s;
    int firsta;
    int lastz;
    for(int i = 0; i < s.size(); i++){
        if(s.at(i) == 'A'){
            firsta = i;
            break;
        }
    }
    for(int i = 0; i < s.size(); i++){
        if(s.at(i) == 'Z'){
            lastz = i;
        }
    }
    cout << lastz - firsta + 1 << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Vec2(T, n, m, xs, x0) vector<vector<T>> xs(n, vector<T>(m, x0))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, h, w, n);
    vector<ll> ans(10); ans[0] = (ll)(h-2)*(w-2);
    unordered_map<ll, int> m;
    Rep(n){
        Cin(int, a, b);
        for(int i : {-1, 0, 1}) for(int j : {-1, 0, 1}){
            if(1 < a+i && a+i < h && 1 < b+j && b+j < w){
                ll k = (ll)(a+i-1)*w+(b+j-1);
                ans[m[k]] --;
                m[k] ++;
                ans[m[k]] ++;
            }
        }
    }
    For(i, 10) Cout(ans[i]);
}


Measured memory_bytes: 36640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define enld endl

int main() {
	lint T;
	cin >> T;
	string S;
	lint out = 0;
	vector<lint>A;
	while (cin >> S) {
		if (S == "HIT") {
			rep(i, A.size()) {
				A[i] += 1;
			}
			A.push_back(1);
		}
		else if (S == "OUT") {
			out++;
			if (out == 3) {
				lint cnt = 0;
				rep(i, A.size()) {
					if (A[i] >= 4) {
						cnt++;
					}
				}
				cout << cnt << endl;
				A.clear();
				out = 0;
			}
		}
		else if (S == "HOMERUN") {
			rep(i, A.size()) {
				A[i] += 4;
			}
			A.push_back(4);
		}
	}
}


Measured memory_bytes: 3072
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;


int main(){
    string str;
    cin >> str;
    int ans = 1000000;
    REP(i, str.size() - 2){
        string a , b, c;
        a= str[i];
        b = str[i + 1];
        c = str[i + 2];
        string x = a + b + c;
        int y = atoi(x.c_str());
        int sa = abs(y - 753);
        ans = min(sa, ans);
    }
    cout << ans << "\n";

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n;
string s,t;
int l=0,r,num_x=0,num_y=0;

void solve(){
    cin >> s;
    s+="#";
    rep(i,s.length()-1){
        if (s[i]=='A') t+="X";
        if (s[i]=='C') t+="#";
        if (s[i]=='B'){
            if (s[i+1]=='C'){
                t+="Y";
                i+=1;
            }else{
                t+="#";
            }
        }
        
    }
    t+="#";
    n=t.length();
    ll ans=0;
    //cout << t << endl;
    rep(i,n){
        if (t[i]=='X') num_x+=1;
        if (t[i]=='Y') num_y+=1;
        if (t[i]=='#') {
            r=i;
            //cout << l << " " << r << " " << num_x << " " << num_y << endl;;
            int c=0;
            Rep(j,l,r){
                if (t[j]=='X') {
                    ans+=r-num_x+c-j;
                    c+=1;
                }
            }
            l=i+1;
            num_x=0;
            num_y=0;
            //cout << ans << endl;
        }
    }
    cout << ans << endl;
}

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

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

typedef long long ll;
const int Nmax = 2e5 + 10;
int cnt[Nmax];
vector<int> a[Nmax];

void dfs(int u, int parent) {
	for (auto& v : a[u]) {
		if (v == parent)
			continue;
		dfs(v, u);
		cnt[u]++;
	}
}

int main() {
	int n;
	cin >> n;
	for (int i = 1; i < n; ++i) {
		int p;
		cin >> p;
		a[--p].push_back(i);
	}
	dfs(0, -1);
	for (int i = 0; i < n; ++i)
		cout << cnt[i] << "\n";
}

Measured memory_bytes: 27748
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch, f;
  while ((ch < '0' || ch > '9') && ch != '-') ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

int const INF = 0x7f7f7f7f, MAXN = 5005, MAXM = 205;
int a[MAXN], b[MAXN][MAXM], x[MAXN][MAXM], y[MAXN][MAXM], stk[MAXN], top;
LL sum[MAXN], mat[MAXN][MAXN];

inline void Add(int a, int b, int c, int d, LL num) {
  mat[a][b] += num;
  mat[c + 1][b] -= num;
  mat[a][d + 1] -= num;
  mat[c + 1][d + 1] += num;
}

int main() {
#define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
  FILEIO("a");
#endif

  int n, m; read(n), read(m);
  for (RI i = 1; i < n; ++i)
    read(a[i]), sum[i] = sum[i - 1] + a[i];
  for (RI i = 1; i <= n; ++i)
    for (RI j = 1; j <= m; ++j)
      read(b[i][j]);
  for (RI j = 1; j <= m; ++j) {
    top = 0;
    b[0][j] = INF;
    stk[++top] = 0;
    for (RI i = 1; i <= n; ++i) {
      while (b[stk[top]][j] < b[i][j]) --top;
      x[i][j] = stk[top];
      stk[++top] = i;
      //      printf("%d %d %d\n", i, j, x[i][j]);
    }
    top = 0;
    b[n + 1][j] = INF;
    stk[++top] = n + 1;
    for (RI i = n; i >= 1; --i) {
      while (b[stk[top]][j] < b[i][j]) --top;
      y[i][j] = stk[top];
      stk[++top] = i;
      //      printf("%d %d %d\n", i, j, y[i][j]);
    }
  }
  for (RI i = 1; i <= n; ++i)
    for (RI j = 1; j <= m; ++j)
      Add(x[i][j] + 1, i, i, y[i][j] - 1, b[i][j]);
 // for (int i = 1; i <= n; ++i) {
//    for (int j = 1; j <= n; ++j)
 //     printf("%lld ", mat[i][j]);
 //   puts("");
//  }
  for (RI i = 1; i <= n; ++i)
    for (RI j = 1; j <= n; ++j)
      mat[i][j] += mat[i - 1][j] + mat[i][j - 1] - mat[i - 1][j - 1];
  LL ans = -1;
  for (RI i = 1; i <= n; ++i)
    for (RI j = i; j <= n; ++j)
      ans = max(ans, mat[i][j] - (sum[j - 1] - sum[i - 1]));
  printf("%lld\n", ans);
  return 0;
}

// created by Daniel yuan


Measured memory_bytes: 209024
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;

int main() {
	int k;
	cin >> k;
	int rem = 0;
	for (int i = 1; i <= k; i++) {
		rem = (rem * 10 + 7) % k;
		if (rem == 0) {
			cout << i;
			return 0;
		}
	} 
	cout << -1;
}


Measured memory_bytes: 3644
#include <iostream>
#include<math.h>
using namespace std;

int main() {
	unsigned long long int a,b,c;
	cin >> a >> b >> c;

	for(int i=1;i<=100;i++){

		if (c == a*i % b) {
			cout << "YES" << endl;
			return 0;
		}

	}
	cout << "NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
#define MOD 1000000007
int m,n;
void solve(int  m,int n)
{
    long long res=1;
    long long x=m;
    while(n>0)
    {
        if(n&1)res=(res*x)%MOD;
        x=(x*x)%MOD;

        n>>=1;
    }
    cout<<res<<endl;

}
int main()
{
//    freopen("in.txt","r",stdin);
    scanf("%d%d",&m,&n);
    solve(m,n);

    return 0;
}

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

int main() {
  int N,A,B,P1,P2;
    cin >> N >> A >> B;
    P1 = A * N;
    P2 = B;
  
  if (P1 <= P2) {
    cout << P1 << endl;
  }
  
  else {
    cout << P2 << endl;
  } 
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
#include <assert.h>
#include <array>

using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mn(x) *min_element((x).begin(),(x).end())
#define mx(x) *max_element((x).begin(),(x).end())
//#define sum(x) accumulate((x).begin(),(x).end(),0ll)
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef  unsigned long long  ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vs;

const ld pi=acos(-1);
const ll inf=(ll)1e9+1;
const int mod=1000000007;
//const int mod=998244353;

int n,m,k;
const int N=1e3+10;





int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    int q,t,u,v,h;
    ll x,a,b,c,d,y,z;
    cin >> d >> t >> a;
    if(t*a>=d){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
    return 0;
}







Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
const int N = 2e5 + 5;
 
int32_t main()
{
	IOS;
	
	ll k,n;
	cin>>k>>n;
	
	if(k<=10){
	    k = (10-k)*100;
	}
	else{
	    k=0;
	}
	
	cout<<n+k<<endl;
    
}

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

int main(){
int x,y,n;
  cin >> x >> y >> n;
  vector<vector<int>> data(n,vector<int>(3));
  for(int i=0;i<n;i++){
  for(int j=0;j<3;j++){
    cin >> data[i][j];
  }
  }
  set<int> a,b,c,d;
  for(int i=0;i<n;i++){
  if(data[i][2]==1) a.insert(data[i][0]);
  if(data[i][2]==2) b.insert(data[i][0]);
  if(data[i][2]==3) c.insert(data[i][1]);
  if(data[i][2]==4) d.insert(data[i][1]); 
  }
  int minx;
   if(!a.empty()) minx=*rbegin(a);
   else       minx=0;
  int maxx;
  if(!b.empty())maxx=*begin(b);
  else          maxx=x;
  
  int miny;
  if(!c.empty())miny=*rbegin(c);
  else         miny=0;
  
  int maxy;
  if(!d.empty())maxy=*begin(d);
  else          maxy=y;
  
  int S;
  if(minx>=maxx) S=0;
  if(minx<maxx){
  if(miny>=maxy) {S=0;}
  if(miny<maxy)  {S=(maxx-minx)*(maxy-miny);}
  }
  
 
  cout << S << endl;
  return 0;
}

Measured memory_bytes: 3608
n, k = map(int, input().strip().split())
p = list(map(int, input().strip().split()))

def calc_exp(n):
    exp=1+(n-1)*0.5
    return exp

tmp=sum(p[:k])
mx=tmp
ind=0
for i in range(1,n-k+1):
    # tmp=sum(p[i:i+k])
    tmp-=p[i-1]
    tmp+=p[i+k-1]
    if mx<tmp:
        ind=i
        mx=tmp
        
ans=0
for i in range(k):
    ans+=1+(p[ind+i]-1)*0.5
    
print(ans)

Measured memory_bytes: 25060
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N, x;
  std::cin >> N >> x;
  std::vector<i64> a;
  tools::read(a, N);

  std::sort(a.begin(), a.end());
  i64 answer = 0;
  for (const i64& a_i : a) {
    if (x >= a_i) {
      x -= a_i;
      ++answer;
    } else {
      x = 0;
    }
  }
  if (x > 0) {
    --answer;
  }

  std::cout << answer << std::endl;
  return 0;
}

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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define sz(a) ((int)a.size())
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll div_num(ll n){
  vl div(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      div[i]++;
    }
  }
  if(n!=1)div[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=div[i];
  }
  return num;
}
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}
long long lopow(ll a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a ;
        a = a * a ;
        n >>= 1;
    }
    return res;
}


//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//vc Alp ={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//cout<<""<<endl;

int main(){
  ll N;cin>>N;
  vl A(N);
  rep(i,N)cin>>A[i];
  ll ans=0;
  vb Atange(N);
  ll cnt =1000;
  for(int i=0;i<N-1;i++){
    if(A[i]<=A[i+1])cnt-= (cnt/A[i])*(A[i]-A[i+1]);  
  
  }
  cout<<max(cnt,1000LL)<<endl;
  
}







Measured memory_bytes: 3648
import java.util.*;
import java.io.*;
public class Main
{
    static int solve(int h,int height[])
    {
        if(h == 1)
        return 0;
        int dp[] = new int[h];
        dp[0]=0;
        dp[1]=getAbsoluteValue(height[0],height[1]);
        for(int i=2;i<h;i++)
        {
            dp[i]=Math.min(dp[i-1]+getAbsoluteValue(height[i],height[i-1]),dp[i-2]+getAbsoluteValue(height[i],height[i-2]));
        }
        return dp[h-1];
   }
    static int getAbsoluteValue(int a,int b)
    {
        return Math.abs(a-b);
    }
    public static void main(String []args)throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(System.out));
        int h = Integer.parseInt(br.readLine());
        int height[] = Arrays.stream(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        bw.write(Integer.toString(solve(h,height)));
        br.close();
        bw.close();
    }
}


Measured memory_bytes: 36308
import java.io.*;
import java.util.*;
import static java.lang.Math.*;

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

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int N = scanner.nextInt();
        int K = scanner.nextInt();
        long[] x = new long[N];
        for (int i = 0; i < N; i++) {
            x[i] = scanner.nextLong();
        }

        long min = Long.MAX_VALUE;
        for (int i = 0; i <= N - K; i++) {
            int l = i;
            int r = i + K -1;
            min = Math.min(min,
                           Math.min(Math.abs(x[l]) + Math.abs(x[r] - x[l]),
                                    Math.abs(x[r]) + Math.abs(x[l] - x[r])
                                    ));
        }
        System.out.println(min);
    }


    private class MyScanner {
        String[] s;int i;BufferedReader br;String reg = " ";
        MyScanner () { s = new String[0];i = 0;br = new BufferedReader(new InputStreamReader(System.in)); }
        public String next() {
            try {
                if (i < s.length) return s[i++]; String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0); i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}


Measured memory_bytes: 51412
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define REP1(i, n) for(int i=1; i<=(n); i++)
#define RREP1(i, n) for(int i=(n); i>=1; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define out(...) printf(__VA_ARGS__)
#if DEBUG
#define debug(...) printf(__VA_ARGS__)
#else
#define debug(...) /* ... */
#endif
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;}

void solve();
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}
/*================================*/
#if DEBUG
#define SIZE 100
#else
#define SIZE 223450
#endif

int N,Q,K;
int A[SIZE];

void solve() {
    cin>>N>>K;
    REP(i,N)cin>>A[i];
    REP(i,N-K) {
        cout << (A[i] < A[i+K] ? "Yes" : "No") << endl;
    }
}



Measured memory_bytes: 5216
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [, K] = input[0].map(Number);
  const L = input[1].map(Number);

  L.sort((a, b) => b - a);

  return L.slice(0, K).reduce((sum, l) => sum + l);
};

console.log(main(read()));


Measured memory_bytes: 29604
import Control.Applicative ((<$>))
import Control.Monad (replicateM, unless)
import Data.List (foldl')
import Data.Vector.Unboxed (Vector, (!), (//))
import qualified Data.Vector.Unboxed as V

main :: IO ()
main = do
  n <- readLn
  unless (n == 0) $ do
    solve n <$> replicateM n (f <$> words <$> getLine) >>= putStrLn
    main
  where f (s:_:ls) = (s, map read ls)

solve :: Int -> [(String, [Int])] -> String
solve n xs = f . minimum . map (\(s, ts) -> (count ts, s)) $ xs
  where ph = foldl' (\h x -> V.accum (+) h [(x,1)]) (V.replicate 31 0) (concatMap snd xs) :: Vector Int
        count = sum . map (\t -> n + 1 - ph ! t)
        f (t, s) = unwords [show t, s]



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

int main()
{
	double N; scanf("%lf",&N);
  	if(int(N)%2!=0)
    {
      cout<<(int(N)/2+1)/N<<endl;
    }
  	else
    {
      cout<<0.5<<endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 2100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
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; }


void solve(){
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    bool ans=false;
    ll A=a,B=b,C=c;
    ll cnt=0;
    while(B<=A){
        B*=2;
        cnt++;
    }
    while(C<=B){
        C*=2;
        cnt++;
    }
    if(cnt<=k) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}

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

    solve(); 


    return 0;
}


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

using namespace std;

#define sz(x) (int)(x.size())
#define fi(a, b) for(int i=a;i<b;++i)
#define fj(a, b) for(int j=a;j<b;++j)
#define fk(a, b) for(int k=a;k<b;++k)
#define pb push_back
#define mp make_pair
typedef long long ll;
/////////////

vector<int> v, cnt;
int n;

void solve(){
	sort(v.begin(), v.end());
	int cur = 1;
	fi(1, sz(v)){
		if(v[i] != v[i-1]){
			cnt.pb(cur);
			cur = 1;
		}else{
			++cur;
		}
	}
	cnt.pb(cur);

	int ans = 0;
	int two = 0;
	fi(0, sz(cnt)){
		if(cnt[i] % 2 == 1){
			ans += (cnt[i] / 2);
		}else{
			ans += (cnt[i] - 2) / 2;
			++two;
		}
	}
	ans += (two / 2) + (two % 2);

	printf("%d\n",n-ans * 2);
}

void read(){
	scanf("%d",&n);
	v.assign(n, 41);
	fi(0, n){
		scanf("%d",&v[i]);
	}
}

void prepare(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
}

int main(){
	prepare();
	read();
	solve();



	return 0;
}

Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[3],i;
    for(i=0;i<3;i++)
        cin>>a[i];
    sort(a,a+3);
    if(a[0]==5&&a[1]==5&&a[2]==7) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 3648
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Diagnostics;
using Enu = System.Linq.Enumerable;

public class Program
{
    public void Solve()
    {
        int N = Reader.Int();
        var A = Reader.IntLine();
        int ans = 0;
        for (int i = 0; i < N; i++)
            if (A[A[i] - 1] == i + 1)
                ans++;
        Console.WriteLine(ans / 2);
    }
}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    static TextReader reader = Console.In;
    static readonly char[] separator = { ' ' };
    static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    static string[] A = new string[0];
    static int i;
    static void Init() { A = new string[0]; }
    public static void Set(TextReader r) { reader = r; Init(); }
    public static void Set(string file) { reader = new StreamReader(file); Init(); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Range(N, Int); }
    public static int[][] IntTable(int H) { return Range(H, IntLine); }
    public static string[] StringArray(int N) { return Range(N, Next); }
    public static string[][] StringTable(int N) { return Range(N, () => Split(Line())); }
    public static string Line() { return reader.ReadLine().Trim(); }
    static string[] Split(string s) { return s.Split(separator, op); }
    static T[] Range<T>(int N, Func<T> f) { var r = new T[N]; for (int i = 0; i < N; r[i++] = f()) ; return r; }
    static string Next() { CheckNext(); return A[i++]; }
    static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}

Measured memory_bytes: 9688
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <string>

#define FOR(i, n) for (int i = 0; i < n; i++)
#define FOR1(i, n) for (int i = 1; i < n; i++)
#define OUT(s) cout << s << endl;
#define IN(a) cin >> a;
#define PACK(a, n) \
  for (int i = 0; i < n; i++) cin >> a[i];
#define PACK1(a, n) \
  for (int i = 1; i < n; i++) cin >> a[i];
#define LIST(a, n) \
  for (int i = 0; i < n; i++) cout << "[" << i << "] " << a[i] << endl;

using namespace std;

const int MAX_N = 100002;
int N;
int A[MAX_N];

int main() {
  string res = "";
  FOR(i, 3) {
    string line;
    cin >> line;
    res += line[i];
  }
  OUT(res);
  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <climits>

using namespace std;

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

//???
class Point {
public:
    double x, y;
    
    Point (double x = 0, double y = 0):x(x), y(y){}
    Point operator + (Point p){return Point(x + p.x, y + p.y);}
    Point operator - (Point p){return Point(x - p.x, y - p.y);}
    Point operator * (double a){return Point(a * x, a * y);}
    Point operator / (double a){return Point(x / a, y / a);}
    
    double norm(){return x*x + y*y;};
    double absolute(){return sqrt(norm());};
    
    bool operator < (const Point &p) const{
        return x != p.x ? x < p.x : y < p.y;
    }
    
    bool operator == (const Point &p) const{
        return equals(x, p.x) && equals(y, p.y);
    }
    
};
typedef Point Vector;                               //????????????

//????????????a,b?????????
double cross(Vector a, Vector b){
    return a.x * b.y - a.y * b.x;
}

int main(){
    
    int n;
    Vector a, b;
    bool convex_flag = true;
    
    cin >> n;
    
    Vector *q = new Vector[n];
    
    for (int i = 0; i < n; i++) {
        cin >> q[i].x;
        cin >> q[i].y;
    }
    
    for (int i = 0; i < n; i++) {
        a = q[(i+1)%n] - q[i];
        b = q[(i+2)%n] - q[i];
        
        if (cross(a, b) < 0) {
            convex_flag = false;
            break;
        }
    }
    
    if(convex_flag) printf("1\n");
    else            printf("0\n");

    return 0;
}

Measured memory_bytes: 1188
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl
#define NL <<"\n"

using namespace std;
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
//#undef NUIP
#ifdef NUIP
#include "benri.h"
#else
#define out(args...)
#endif
#ifdef __cpp_init_captures
template<typename T>vector<T> table(int n, T v){ return vector<T>(n, v);}
template <class... Args> auto table(int n, Args... args){auto val = table(args...); return vector<decltype(val)>(n, move(val));}
#endif
const ll MOD=1e9+7; //998244353

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout<<fixed<<setprecision(0);
	string S;
  cin>>S; S;
	int n=S.size()+1;
	vector<int> a(n,MOD);
	queue<int> que;
	rep(i,n)if((!i || S[i-1]=='>') && (i==n-1 || S[i]=='<')){ a[i]=0; que.emplace(i);}
	rep(i,n)if((!i || S[i-1]=='<') && (i==n-1 || S[i]=='>')){ a[i]=0; }
	while(que.size()){
		int i=que.front(); que.pop();
		if(i && MN(a[i-1],a[i]+1)) que.emplace(i-1);
		if(i+1<n && MN(a[i+1],a[i]+1)) que.emplace(i+1);
	}
	rep(i,n)if((!i || S[i-1]=='<') && (i==n-1 || S[i]=='>')){
		if(i) MX(a[i],a[i-1]+1);
		if(i+1<n) MX(a[i],a[i+1]+1);
	}
	out(a,1);
	cout<<accumulate(all(a),0ll)<<endl;
	return 0;
}


Measured memory_bytes: 3228
import itertools

N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
a = b = 0
cnt = 0
for ptn in itertools.permutations(range(1,N+1)):
    cnt += 1
    ok1 = True
    for i in range(N):
        if P[i] != ptn[i]:
            ok1 = False
            break
    if ok1: a = cnt
    ok2 = True
    for i in range(N):
        if Q[i] != ptn[i]:
            ok2 = False
            break
    if ok2: b = cnt
print(abs(a-b))


Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = ((B)-1); I >= (A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define pri(a) cout << (a) << endl
class comb{
	vector<ll> f,fr;
	ll MOD;
	public:
	//a^(p-1) = 1 (mod p)(p->Prime numbers)
	//a^(p-2) = a^(-1)
	ll calc(ll a,ll b,ll p){//a^(b) mod p   
		if(b==0)return 1;
		ll y = calc(a,b/2,p);y=(y*y)%p;
		if(b & 1) y = (y * a) % p;
		return y;
	}
	void init(ll n,ll mod){//input max_n
		MOD = mod;
		f.resize(n+1);
		fr.resize(n+1);
		f[0]=fr[0]=1;
		for(ll i=1;i<n+1;i++){
			f[i] = (f[i-1] * i) % mod;
			fr[i] = calc(f[i],mod-2,mod);
		}
	}
	ll nCr(ll n,ll r){
		return f[n] * fr[r] % MOD * fr[n-r] % MOD;
	}
};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	ll n = s.size();
	comb co;
	co.init(1000000,MOD);
	vector<ll> a(n+1,0),b(n+1,0),c(n+1,0),h(n+1,0);
	FOR(i,1,n+1){
		a[i] = a[i-1];
		b[i] = b[i-1];
		c[i] = c[i-1];
		h[i] = h[i-1];
		if(s[i-1]=='A')a[i]++;
		if(s[i-1]=='B')b[i]++;
		if(s[i-1]=='C')c[i]++;
		if(s[i-1]=='?')h[i]++;
	}
	ll ans = 0;
	FOR(i,1,n-1){
		ll j = i+1;
		if(s[i]=='B'){
			ans += ( a[j]*(c[n]-c[j])*co.calc(3,h[n],MOD) ) % MOD;
			ans %= MOD;
			ans += ( a[j]*(h[n]-h[j])*co.calc(3,h[n]-1,MOD) ) % MOD;
			ans %= MOD;
			ans += ( h[j-1]*(c[n]-c[j])*co.calc(3,h[n]-1,MOD) ) % MOD;
			ans %= MOD;
			ans += ( h[j-1]*(h[n]-h[j])*co.calc(3,h[n]-2,MOD) ) % MOD;
			ans %= MOD;
		}
	}
	FOR(i,1,n-1){
		ll j = i+1;
		if(s[i]=='?'){
			ans += ( a[j]*(c[n]-c[j])*co.calc(3,h[n]-1,MOD) ) % MOD;
			ans %= MOD;
			ans += ( a[j]*(h[n]-h[j])*co.calc(3,h[n]-2,MOD) ) % MOD;
			ans %= MOD;
			ans += ( h[j-1]*(c[n]-c[j])*co.calc(3,h[n]-2,MOD) ) % MOD;
			ans %= MOD;
			ans += ( h[j-1]*(h[n]-h[j])*co.calc(3,h[n]-3,MOD) ) % MOD;
			ans %= MOD;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 19280
#include <cstdio>
#include <cmath>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

    cout << n - k + 1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;

bool xt[16009][8009], yt[16009][8009];

void go(bool st[][8009], vector<int> &S, int x, int i, int &f, int d) {
	if(x == d && i == S.size()) f = 1;
	if(i == S.size()) return;
	st[x+8000][i] = 1;
	if(!st[x+S[i]+8000][i+1]) go(st, S, x+S[i], i+1, f, d);
	if(!st[x-S[i]+8000][i+1]) go(st, S, x-S[i], i+1, f, d);
}

int main() {
	vector<int> XS, YS;
	string S; cin >> S;
	int N = S.size(), x, y; scanf("%d%d",&x,&y);
	for(int i=0, c=0, f=0; i<N; i++) {
		if(S[i] == 'F') ++c;
		if(S[i] == 'T' || i+1 == N) {
			if(f == 0) {
				if(YS.empty()) x -= c;
				else XS.push_back(c);
			}
			if(f == 1) YS.push_back(c);
			f = !f; c = 0;
		}
	}
	int xf = 0, yf = 0;
	go(xt, XS, 0, 0, xf, x); go(yt, YS, 0, 0, yf, y);
	if(xf && yf) puts("Yes");
	else puts("No");
	return 0;	
}

Measured memory_bytes: 125184
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
const LL MOD = 998244353LL;
int x[200], y[200];
LL p2[201];
bool used[200][200];
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> y[i];
	}
	p2[0] = 1;
	for (int i = 1; i <= N; i++) p2[i] = (p2[i - 1] * 2) % MOD;
	LL ans = p2[N];
	LL sub = 1 + N;
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			if (used[i][j]) continue;
			vector<int> v;
			for (int k = 0; k < N; k++) {
				if ((x[j] - x[i])*(y[k] - y[i]) == (y[j] - y[i])*(x[k] - x[i])) {
					v.push_back(k);
				}
			}
			for (int k = 0; k < v.size(); k++) {
				for (int l = 0; l < v.size(); l++) used[v[k]][v[l]] = 1;
			}
			(sub += p2[v.size()]) %= MOD;
			sub = (sub - (1 + v.size()) + MOD) % MOD;
		}
	}
	ans = (ans - sub + MOD) % MOD;
	cout << ans << endl;
}

Measured memory_bytes: 384
/**
 *    author:  tourist
 *    created: 21.12.2019 18:43:58       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<bool> win(k + 1);
  for (int i = 1; i <= k; i++) {
    for (int x : a) {
      if (i >= x && !win[i - x]) {
        win[i] = true;
        break;
      }
    }
  }
  cout << (win[k] ? "First" : "Second") << '\n';
  return 0;
}


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max(0, min(b, d) - max(a, c)) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long 
const int N = 2e5 + 7;
int dp[N];

int recur(int id, int n, int a[], int k)
{
    if(id >= n - 1)
        return 0;

    if(dp[id] != -1)
        return dp[id];

    int ans = INT_MAX;

    for(int i = 1; i <= k; i++)
    {
        if(id + i <= n - 1)
            ans = min(ans, abs(a[id + i] - a[id]) + recur(id + i, n, a, k));
    }
    
    //ans = min(ans, abs(a[id + 2] - a[id]) + recur(id + 2, n, a));

    return dp[id] = ans;
}

int32_t main()
{
    int n, k;
    cin >> n >> k;
    int a[n];

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

    memset(dp, -1, sizeof(dp));
    cout << recur(0, n, a, k) << "\n";

}

Measured memory_bytes: 11904
from math import floor, sqrt

x = int(input())

if x == 2:
    print(x)
    exit()

if x % 2 == 0:
    x += 1

while True:
    stop = floor(sqrt(x)) + 1
    for i in range(3, stop, 2):
        if x % i == 0:
            x += 2
            break
    else:
        break
print(x)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
using namespace std;
/*
Before Submitting, check:(Delete them before submitting)
*int or long long
*the range of every array(will it get an RE and is it bg enough?)
*special cases(0,1...)
*/
string s,bef="",aft="";
int q,t,f,re=0;
char c,buf[100010];
int main(){
	scanf("%s%d",&buf,&q);
	s=buf;
	while(q--)
	{
		scanf("%d",&t);
		if(t==1)
		{
			re++;
		}
		else
		{
			scanf("%d %c",&f,&c);
			if((f+re)%2==0)
			{
				aft+=c;
			}
			else
			{
				bef+=c;
			}
		}
	}
	reverse(bef.begin(),bef.end());
	s=bef+s+aft;
	if(re%2==1)
	{
		reverse(s.begin(),s.end());
	}
	printf("%s\n",s.c_str());
	return 0;
}

Measured memory_bytes: 1436
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)	for(long long int i=a; i<n; i++)
#define loop(i,a,n)	for(long long int i=a; i>=n; i--)

int main() 
{
	ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(0);
	
	long long int ct=0,a;
	cin>>a;
	long long int b[a];
	map<long long int,long long int> m;
	forr(i,0,a)
	{
		cin>>b[i];
		m[b[i]]++;
		ct+=b[i];
	}
	long long int q;
	cin>>q; 
	while(q--)
	{
		long long int l,r;
		cin>>l>>r;
		ct-=m[l]*l;
		ct+=m[l]*r;
		m[r]+=m[l];
		m[l]=0;
		cout<<ct<<'\n';
	}
	
	return 0; 	
}

Measured memory_bytes: 10352
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
struct recoder{
    ll s, t, c;
};
 
bool compare(recoder a, recoder b){
    if(a.s == b.s)return a.c < b.c;
    else return a.s < b.s;
}
bool compare_c(recoder a, recoder b){
    if(a.c == b.c)return a.s < b.s;
    else return a.c < b.c;
}
int main(){
    ll n, c;
    cin >> n >> c;
    vector<recoder> rec(n);
    rep(i, n)cin >> rec[i].s >> rec[i].t >> rec[i].c;
    sort(ALL(rec), compare_c);

    vector<recoder> tmp;
    rep(i, rec.size()){
        int no = i;
        i++;
        while(rec[no].c == rec[i].c && rec[no].t == rec[i].s){
            rec[no].t = rec[i].t;
            i++;
        }i--;
        tmp.push_back(rec[no]);
    }
    // cout << endl;
    // rep(i, tmp.size())cout << tmp[i].s << " " << tmp[i].t << endl;
    sort(ALL(tmp), compare);
    for(int i = 1; i <= 35; ++i){
       vector<pair<ll, ll>> p(i);
       rep(j, i)p[j].first = 0, p[j].second = 0;
       bool flag = true;
       rep(j, tmp.size()){
           int pos = 0;
           if(p[pos].second == tmp[j].c)while(p[pos].first > tmp[j].s && pos < i)pos++;
           else while(p[pos].first > (tmp[j].s-1) &&  pos < i)pos++;
           if(pos >= i){
               flag = false;
               break;
           }
           p[pos].first = tmp[j].t;
           p[pos].second = tmp[j].c;
       }
       if(flag){
           cout << i << endl;
           return 0;
       }
   }
}

Measured memory_bytes: 7284
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<vin> vvin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
const int MOD=1e9+7;
vector<pair<ll,int>> factorize(ll n) {
    vector<pair<ll,int>> res;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i != 0) continue;
        res.emplace_back(i,0);
        while (n % i == 0) {
            n /= i;
            res.back().second++;
        } 
    }
    if (n != 1) res.emplace_back(n,1);
    return res;
}
int main(){
  ll n,ans=0;cin>>n;
  vector<pair<ll,int>> res=factorize(n);
  rep(i,0,res.size()){
    ll tmp=0;
    rep(j,1,res[i].second+3){
      tmp+=j;
      if(tmp>res[i].second){ans+=j-1;break;}
    }
  }
  cout<<ans<<endl;
}


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

int kaijou(int n) {
    if (n == 0)
        return 1;
    else 
        return n * kaijou(n-1);
}

void solve() {
    int N; cin >> N;
    vector<pair<int,int>> m(N);
    vector<int> n(N);
    double sum;
    for(int i = 0; i < N; i++) {
        cin >> m.at(i).first >> m.at(i).second;
        n.at(i) = i;
    }
    do {
        for(int i = 0; i < N-1; i++) {
            double dx = m.at(n.at(i)).first - m.at(n.at(i+1)).first;
            double dy = m.at(n.at(i)).second - m.at(n.at(i+1)).second;
            sum += sqrt(dx*dx + dy*dy);
        }
    }while(next_permutation(n.begin(),n.end()));

    printf("%.10f\n",sum/kaijou(N));
}

int main() {
    solve();
}


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

// Author: Ashish

int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n,m;
  cin>>n>>m;
  n=n%m;
  n=min(n,m-n);
  cout<<n;

 	return 0;
}

Measured memory_bytes: 256