akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T> void OUT(T && a) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

vector<pair<LL, LL>> prime_factorization(LL x) {
	assert(x > 0);
	vector<pair<LL, LL>> f;
	for(LL i = 2; i <= x; i++) {
		if(i * i > x) { i = x; }
		if(x % i == 0) {
			f.EB(i, 0);
			while(x % i == 0) { f.back().SE++; x /= i; }
		}
	}
	return f;
}

vector<LL> divisors(LL x) {
	auto pf = prime_factorization(x);
	vector<LL> d = { 1 };
	for(auto e: pf) {
		int ds = d.size();
		inc(i, ds) {
			LL v = d[i];
			inc(j, e.SE) { v *= e.FI; d.PB(v); }
		}
	}
	sort(ALL(d));
	return d;
}

int main() {
	IN(LL, n);
	
	LL ans = SI(divisors(n - 1)) - 1;
	
	auto D = divisors(n);
	RF(d, D) {
		if(d == 1) { continue; }
		
		LL nn = n;
		while(nn % d == 0) {
			nn /= d;
			if((nn - 1) % d == 0) { ans++; }
		}
	}
	OUT(ans);
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int n, x[110], y[110], h[110];

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++)cin >> x[i] >> y[i] >> h[i];
	for (int i = 0; i <= 100; i++)for (int j = 0; j <= 100; j++) {
		int p = 0;
		bool bl = true;
		for (int k = 0; k < n; k++) {
			if (h[k]) {
				p = h[k] + abs(x[k] - i) + abs(y[k] - j);
				break;
			}
		}
		for (int k = 0; k < n; k++) {
			if (h[k] && p != h[k] + abs(x[k] - i) + abs(y[k] - j))bl = false;
			if (h[k] == 0 && p > abs(x[k] - i) + abs(y[k] - j))bl = false;
		}
		if (bl) {
			cout << i << " " << j << " " << p << endl;
			return 0;
		}
	}
}

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

int main()
{
	int t=0, h=0;
	int a, b, c;
	string buf;
	while(cin>>buf){
		sscanf(buf.c_str(),"%d,%d,%d", &a, &b, &c);
		if(a==b) h++;
		if(a*a+b*b==c*c) t++;
	}
	cout<<t<<endl<<h<<endl;
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
//#define int ll
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int 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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  int H, W;
  cin >> H >> W;
  int N;
  cin >> N;
  vi a(N);
  rep(i, N) {
    cin >> a[i];
  }
  
  vvi col(H, vi(W));
  int h = 0; int w = 0;
  int c = 1;
  rep(i, N) {
    rep(j, a[i]) {
      col[h][w] = c;
      if(h % 2 == 0) {
        w ++;
      } else {
        w --;
      }
      if(w == W) {
        w = W - 1;
        h ++;
      } else if(w == -1) {
        w = 0;
        h ++;
      }
    }
    c ++;
  }
  
  rep(i, H) {
    rep(j, W) {
      cout << col[i][j] << " ";
    }
    cout << endl;
  }
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

struct RollingHash{
  LL H, W;
  const LL B1, B2, M;
  vector<vector<LL>> h;
  VL pow1, pow2;
  RollingHash(VS& str): B1(1009), B2(1007), M(1000000009){
	H = str.size(), W = str[0].size();
	h.assign(H+1, vector<LL>(W+1, 0));
	pow1.assign(H+1,1);
	pow2.assign(W+1,1);

	REP(i,H)
	  pow1[i+1] = pow1[i] * B1 % M;
	REP(i,W)
	  pow2[i+1] = pow2[i] * B2 % M;
	
	REP(y,H) REP(x,W){
	  h[y+1][x+1] = (h[y][x+1] * B1 % M + h[y+1][x] * B2 % M
						+ (M - h[y][x] * B1 % M * B2 % M) + str[y][x]) % M;
	}
  }

  LL hash(int x1, int y1, int x2, int y2){
	return (h[y2][x2]
			+ (M - h[y1][x2] * pow1[y2-y1] % M)
			+ (M - h[y2][x1] * pow2[x2-x1] % M)
			+ (h[y1][x1] * pow1[y2-y1] % M * pow2[x2-x1] % M)) % M;
  }
};



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

  int H, W;
  cin >> H >> W;
  VS vs(H);
  REP(y,H) cin >> vs[y];
  int R, C;
  cin >> R >> C;
  VS pat(R);
  REP(y,R) cin >> pat[y];

  RollingHash rs(vs), pt(pat);
  LL target = pt.hash(0, 0, C, R);
  FOR(y,R,H+1) FOR(x,C,W+1){
	if(rs.hash(x-C, y-R, x, y) == target){
	  cout << y-R << " " << x-C << endl;
	}
  }

  return 0;
}

Measured memory_bytes: 20740
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
int gcd(int a,int b){if(a<b)swap(a,b);int c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};


int main(){
  int n, k; cin >> n >> k;
  int sum = 0;
  vector<bool> p(n, 0);
  rep(i, k){
    int d; cin >> d;
    rep(i, d){
      int a; cin >>a;
      p[a - 1] = 1;
    }
  }
  rep(i, n){
    if (!p[i]) sum ++;
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 3632
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
const int N = 2e7 + 7;
const int mod=1e9+7;
const int INF=1e18+7;
const int dx[] = {-1, 1, 0,  0}; // UDLR
const int dy[] = { 0, 0, -1, 1}; // UDLR
inline int maximum (int a,int b) {int c=a>b?a:b; return c;}
inline int minimum (int a,int b) {int c=a>b?b:a; return c;}

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

       int n,ans=0; cin>>n; tuple<int,int,int> A[n+1]; vector<vector<int>> dp(n+1,vector<int>(3,0));
       for(int i=1;i<=n;i++){
         int a,b,c; cin>>a>>b>>c;
         A[i]={a,b,c};
       }
       dp[1][0]=get<0>(A[1]); dp[1][1]=get<1>(A[1]); dp[1][2]=get<2>(A[1]);
       ans=max({dp[1][0],dp[1][1],dp[1][2]});
       for(int i=2;i<=n;i++){
         for(int j=0;j<3;j++){
          for(int k=0;k<3;k++){
            if(k==j) continue;
            if(j==0) dp[i][j]=maximum(dp[i][j],dp[i-1][k]+get<0>(A[i]));
            if(j==1) dp[i][j]=maximum(dp[i][j],dp[i-1][k]+get<1>(A[i]));
            if(j==2) dp[i][j]=maximum(dp[i][j],dp[i-1][k]+get<2>(A[i]));
          }
           ans=maximum(ans,dp[i][j]);
         }
       }
          cout<<ans;
 return 0;
 }


Measured memory_bytes: 11100
import numpy as np
#from numba import njit

def getVar():
    return map(int, input().split())
def getArray():
    return np.array(list(map(int, input().split())))

def main():
    N = int(input())
    A = list(map(int,input().split()))

    m = 1
    upper = 1000000000000000000

    if 0 in A:
        print(0)
        return
        
    for a in A:
        m *= a
        if m > upper:
            print(-1)
            return

    print(m)

main()

Measured memory_bytes: 40080
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
using namespace std;
typedef long long ll;
#define INF 2000000000
int main() {
	int n, k, ans = 0, t = 0;
	cin >> n >> k;
	while (k--) {
		cin >> t;
		ans += t;
	}
	if (n >= ans)cout << n - ans << endl;
	else cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 3596
#include<stdio.h>
int main()
{
  int y=0;
  int m=0;
  scanf("%d %d",&y,&m);
  if(y>12)printf("%d",m);
  if(y<13 && y>5)printf("%d",m/2);
  if(y<6)printf("0");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c;
    cin >> a >> b >> c;
    
    int tmp;
    if(a <= b){
        tmp = a;
        a = b;
        b = tmp;
    }
    
    if(b <= c){
        tmp = b;
        b = c;
        c = tmp;
    }
    
    if(a <= b){
        tmp = a;
        a = b;
        b = tmp;
    }
    
    
    cout << a*10 + b + c << endl;
    
    
}


Measured memory_bytes: 256
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#pragma region macro
#include <bits/stdc++.h>
typedef long long int64;
using namespace std;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const int64 INF = 1LL << 62;
const int inf = 1<<30;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
#define bn '\n'
template <typename T>
ostream& operator<<(ostream& os, const vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T,typename S>
ostream& operator<<(ostream& os, pair<T,S> const&P){
    os << "(";
    os << P.first;
    os << " , ";
    os << P.second;
    os << ")";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
    os<<endl;
    return os;
}
template <typename T,typename S>
ostream& operator<<(ostream& os, map<T,S> const&M){
    for(auto e:M){
        os<<e;
    }
    os<<endl;
    return os;
}
vector<pair<int,int>> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)};
#pragma endregion
//fixed<<setprecision(10)<<ans<<endl;

int64 solve(int64 S,vector<int64> const& A){
    int64 res = 0, now = 0;
    int l = 0, N = A.size();
    REP(r,N){
        now += A[r];
        while(now>S) now-=A[l++];
        res += r-l+1;
    }
    return res;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N,Q;
    cin >> N >> Q;
    vector<int64> A(N);
    REP(i,N) cin >> A[i];

    REP(i,Q){
        int64 x; cin >> x;
        cout << solve(x,A) << bn;
    }
    
}


Measured memory_bytes: 3628
K,N = map(int, input().split())
li = list(map(int, input().split()))
max_len = 0
for i in range(N-1):
    if abs(li[i] - li[i+1]) > max_len:
        max_len = abs(li[i] - li[i+1])
if (K - max(li)) + min(li) > max_len:
    max_len = (K - max(li)) + min(li)
print(K - max_len)

Measured memory_bytes: 32372
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7, N = 2e5 + 7;

int a[N], b[N];

signed main()
{
	IO_OP;
	
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 0; i < n; i++) cin >> b[i];
	auto pre = [&](int i) {
		return (i + n - 1) % n;
	};
	auto nxt = [&](int i) {
		return (i + 1) % n;
	};
	priority_queue<pi> pq;
	ll ans = 0;
	for(int i = 0; i < n; i++) {
		if(b[i] < a[i]) return cout << -1 << endl, 0;
		if(b[i] > a[i]) pq.push({b[i], i});
	}
	while(pq.size()) {
		int i = pq.top().S; pq.pop();
		if(b[i] - (b[pre(i)] + b[nxt(i)]) < a[i]) return cout << -1 << endl, 0;
		int cnt = (b[i] - a[i]) / (b[pre(i)] + b[nxt(i)]);
		b[i] -= cnt * (b[pre(i)] + b[nxt(i)]);
		ans += cnt;
		if(b[i] > a[i]) {
			pq.push({b[i], i});
		}
	}
	cout << ans << endl;
	

}






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

int main(){
	string s;
	cin >> s;
	int ans(0);
	rep(i,s.size()){
		if(s[i] == '+') ans++;
		else ans--;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
let n = stdin.ReadLine() |> int
let w = stdin.ReadLine().Split() |> Array.map int
let rec loop s c l =
    if s = n then (c :: l)
    elif w.[s - 1] >= w.[s] then loop (s + 1) (c + 1) l
    else loop (s + 1) 0 (c :: l)
loop 1 0 [] |> List.max |> printfn "%d"

Measured memory_bytes: 30296
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
ll D;
ll c[26];
ll s[366][26];
ll t[366];
ll score(ll days){
	ll ans=0;
	ll last[26];
	rep(i,26)last[i]=0;
	for(ll d=1;d<=days;d++){
		ans+=s[d][t[d]];
		last[t[d]]=d;
		rep(i,26){
			ans-=c[i]*(d-last[i]);
		}
	}
	return ans;
}
int main(){
	cin>>D;
	rep(i,26)cin>>c[i];
	for(ll d=1;d<=D;d++)rep(j,26)cin>>s[d][j];
	for(ll d=1;d<=D;d++){
		cin>>t[d];
		t[d]--;
	}
	for(ll d=1;d<=D;d++){
		cout<<score(d)<<endl;
	}
}


Measured memory_bytes: 3704
#include "bits/stdc++.h"
using namespace std;
typedef long long lint;
#define repi(i,a,b) for(lint i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define all(x) (x).begin(),(x).end()
#define tsort(v) sort((v).begin(), (v).end())
#define trev(v) tsort(v); reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#ifdef tqktmp_1
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

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

    lint a,b, j=1;cin>>a>>b;
    vector<lint> c(2*b);
    rep(i, 2*b)cin>>c[i];
    tsort(c);
    lint i=0;
    while(i<a){
        co(cnt(c, i+1));i++;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int linearSearch(int a[], int n, int key)
{
  int i = 0;
  a[n] = key;

  for(i = 0; i < n; i++){
    if(a[i] == key)  return 1;
  }
  return 0;
}

int main(void)
{
  int a[10000], i, j, n, q, key, result = 0;

  scanf("%d", &n);

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

  scanf("%d", &q);

  for(j = 0; j < q; j++){
    scanf("%d", &key);
    if(linearSearch(a, n, key)){
      result++;
    }
  }
  printf("%d\n", result);

  return 0;
}



Measured memory_bytes: 2036
// 問題の URL を書いておく
// 

#include <algorithm>
#include <bitset>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

#define rep(i, n) for(int i = 0; i < (int)(n); ++i)

const int64_t MAX = 1000000000000001;
const int64_t DIGIT = 26;

int main(int, const char**)
{
    int64_t n;
    cin >> n;
    int64_t base = 0;
    int64_t c = 1;
    int64_t dn = 0;
    while(base < n)
    {
        auto old = c;
        c *= DIGIT;
        if(c / DIGIT != old)
        {
            abort();
        }
        base += c;
        dn++;
    }
    auto ob = n - (base - c) - 1;

    Print(dn);
    Print(ob);    

    string ans = "";
    rep(i, dn)
    {
        auto index = ob % DIGIT;
        ans = (char)('a' + index) + ans;
        ob -= index;
        ob /= DIGIT;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
from collections import deque
import sys
input = sys.stdin.readline
n = int(input())
As = sorted([int(input()) for i in range(n)])
q = deque(As[1:])
# 初期化
ans = 0
cnt = 1
p1 = As[0]
p2 = As[0]
flg = False
while True:
    if len(q) == 0: break
    if flg:
        n1 = q.popleft()
    else:
        n1 = q.pop()
    ans += abs(p1-n1)
    p1 = n1

    if len(q) == 0: break
    if flg:
        n2 = q.popleft()
    else:
        n2 = q.pop()
    ans += abs(p2-n2)
    p2 = n2

    flg = not flg

# 初期化(小さい順)
As = As[::-1]
ans2 = 0
p1 = As[0]
p2 = As[0]
q = deque(As[1:])
flg = False
while True:
    if len(q) == 0: break
    if flg:
        n1 = q.popleft()
    else:
        n1 = q.pop()
    ans2 += abs(p1-n1)
    p1 = n1

    if len(q) == 0: break
    if flg:
        n2 = q.popleft()
    else:
        n2 = q.pop()
    ans2 += abs(p2-n2)
    p2 = n2

    flg = not flg


print(max(ans,ans2))

Measured memory_bytes: 14768
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:https://atcoder.jp/contests/dp/tasks/dp_a>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int N; cin >> N;
    vector<ll> h(N); for(auto& in:h) cin >> in;
    vector<ll> dp(N,LINF);
    dp[0] = 0;
    for(int i = 0; i < N-1;i++){
        dp[i+1] = min(dp[i+1],dp[i] + abs(h[i]-h[i+1]));
        if(i!=N-2) dp[i+2] = min(dp[i+2],dp[i]+abs(h[i]-h[i+2]));
    }
    res = dp[N-1];
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 1792
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define debug(v) cout << #v<< ": " << v <<endl;
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;
ll INF = 1LL<<60;
ll M = 1000000007;

int main(){
    ll n, m, k; cin >> n >> m >> k;
    vll a(n), b(m);
    rep(i, 0, n){
        cin >> a[i];
    }
    rep(i, 0, m){
        cin >> b[i];
    }
    vll A(n+1), B(m+1); A[0] = 0; B[0] = 0;
    ll s = 0, t = 0;
    rep(i, 0, n){
        s += a[i];
        A[i+1] = s;
    }
    rep(i, 0, m){
        t += b[i];
        B[i+1] = t;
    }
    ll mx = 0;
    rep(i, 0, n+1){
        ll K = k;
        K -= A[i];
        if(K < 1){
            if(K >= 0){
                mx = max(mx, i);
            }
            continue;
        }
        ll f = upper_bound(B.begin(), B.end(), K) - B.begin() - 1;
        if(i + f > mx){
            //prtl(i);
        }
        mx = max(mx, i+f);
    }
    prtl(mx);
}




Measured memory_bytes: 9540
//Date and time of submission: 
 
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+5;
double r;
int main() {
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	cin>>r;
	double c=2*M_PI*r;
	cout<<fixed<<setprecision(9)<<c;
	return 0;
}


Measured memory_bytes: 3764
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;

struct Node{
    int num;
    Node* parent;
    Node* right;
    Node* left;
};

struct Node node[25];

int get_sibling(int n){
    if(!node[n].parent)
        return -1;
    struct Node *r = node[n].parent->right;
    struct Node *l = node[n].parent->left;
    if(!(r && l)){
        return -1;
    }
    if(r->num == n){
        return l->num;
    }
    if(l->num == n){
        return r->num;
    }
    return -1;
}

int calc_degree(int n){
    int num = 0;
    if(node[n].right)
        num++;
    if(node[n].left)
        num++;
    return num;
}

int calc_depth(int n){
    if(!node[n].parent)
        return 0;
    return calc_depth(node[n].parent->num) + 1;
}

int calc_height(int n){
    if((!node[n].left) && (!node[n].right)){
        return 0;
    }
    if(!node[n].left){
        return calc_height(node[n].right->num) + 1;
    }
    if(!node[n].right){
        return calc_height(node[n].left->num) + 1;
    }
    return max(calc_height(node[n].left->num), calc_height(node[n].right->num)) + 1;
}

string get_type(int n){
    if(!node[n].parent){
        return string("root");
    }
    if(calc_height(n) == 0){
        return string("leaf");
    }
    return string("internal node");
}

void output(int n){
    for(int i = 0; i < n; i++){
        printf("node %d: ", i);

        if(node[i].parent){
            printf("parent = %d, ", node[i].parent->num);
        }else{
            printf("parent = -1, ");
        }

        printf("sibling = %d, ", get_sibling(i));

        printf("degree = %d, ", calc_degree(i));

        printf("depth = %d, ", calc_depth(i));

        printf("height = %d, ", calc_height(i));

        cout << get_type(i);

        printf("\n");

    }
}

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

    for(int i = 0; i < n; i++){
        node[i].parent = NULL;
        node[i].right = NULL;
        node[i].left = NULL;
    }

    for(int i = 0; i < n; i++){
        int nm, a, b;
        scanf("%d %d %d", &nm, &a, &b);

        node[nm].num = nm;

        if(a != -1){
            node[nm].left = &(node[a]);
            node[a].parent = &(node[nm]);
        }
        if(b != -1){
            node[nm].right = &(node[b]);
            node[b].parent = &(node[nm]);
        }
    }

    output(n);
}



Measured memory_bytes: 3356
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int n,count=0;
  cin >> n;
  long long int a[n],b[n];
  for (int i=0;i<n;i++)cin >>a[i] >>b[i];
  for(int i=n-1;i>=0;i--){
    long long int k=b[i]-((a[i]+count)%b[i]);
    if (k==b[i]) k=0;
    count+=k;
  }
  cout << count <<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int n;
void dfs(vector<int> ha,int mx){
    if(ha.size()==n){
        string s;
        for(int i=0;i<ha.size();i++)
        s+=(char)(ha[i]-1+'a');
        puts(s.c_str());
        return;
    }
    for(int i=1;i<=mx;i++){
        ha.pb(i);
        dfs(ha,max(mx,i+1));
        ha.pop_back();
    }
}
int main(){
    cin>>n;
    vector<int> o;
    o.pb(1);
    dfs(o,2);
    return 0;
}

Measured memory_bytes: 1536
N, K = list(map(int, input().split()))
A = [0]+list(map(int, input().split()))
n = 1
c = 0
while n <= K:
    n *= 2
    c += 1
# print(c)
L = [[0]*(N+1) for _ in range(c)]
L[0] = A
for i in range(1, c):
    for j in range(N+1):
        L[i][j] = L[i-1][L[i-1][j]]
# print(L)

p = 1
for i in range(c):
    if (K >> i) & 1:
        p = L[i][p]
print(p)

Measured memory_bytes: 175596
//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define db double
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define mem(x,val) memset(x,val,sizeof x)
#define Swap(a,b,n) for(int I=0;I<=n;I++) swap(a[I],b[I])
#define PC __builtin_popcountll
#ifdef DEBUG
	#define debug(A,args...) fprintf(stderr,A,##args)
#else
	#define debug(A,args...) 
#endif
namespace mine
{
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
	template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
	ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
	bool IN(ll x,ll l,ll r){return l<=x and x<=r;}
	void GG(){puts("No");exit(0);}
	
	const db eps=1e-8;
	const int INF=0x3f3f3f3f;
	const int MOD=1e9+7;
	int mm(const int x){return x>=MOD?x-MOD:x;}
	template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
	ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int M=5e6+10;
	ll fac[M],facinv[M],Inv[M];ll C(int n,int m){return n<0 or n<m?0:fac[n]*facinv[m]%MOD*facinv[n-m]%MOD;}
	void PRE()
	{
		fac[0]=1;fo(i,1,M-1) fac[i]=fac[i-1]*i%MOD;
		facinv[M-1]=invm(fac[M-1]);fd(i,M-1,1) facinv[i-1]=facinv[i]*i%MOD;
		Inv[1]=1;fo(i,2,M-1) Inv[i]=(MOD-MOD/i)*Inv[MOD%i]%MOD;
	}
	const int N=4e3+10;
	//------------------FIXED------------------
	int dp[N][N];
	void main()
	{
		int n=qread(),m=qread(),K=qread()-1;int L=(n+m-1)/K;dp[0][0]=1;int ans=0;
		fo(l,1,L) fo(sum,0,m) if(dp[l-1][sum]) fo(now,0,K) if(sum+now<=m)
		{
			add(dp[l][sum+now],dp[l-1][sum]);
			if(now and (sum+now-m)%K==0 and l*K-(sum+now)<=n-1) add(ans,dp[l-1][sum]);
		}write(ans);
	}
};//变量重名！
signed main()
{
	#ifdef DEBUG
	//freopen("a.in","r",stdin);
	freopen("z.txt","r",stdin);
	//freopen("a.out","w",stdout);
	#endif
	srand(time(0));
	mine::PRE();//线性预处理模意义
	mine::main();
	debug("\n---------------------Zory---------------------\nTime: %.2lf s",1.0*clock()/CLOCKS_PER_SEC);
}

Measured memory_bytes: 178688
N = int(input())
S = [(input(), 0) for i in range(N)]
t = (input(), 1)
S += t,
S.sort(key=lambda x: (x[0].replace(*'?z'), 1^x[1]))
l = S.index(t)+1
S.sort(key=lambda x: (x[0].replace(*'?a'), x[1]))
r = S.index(t)+1
print(*range(l, r+1))

Measured memory_bytes: 5728
import sys
sys.setrecursionlimit(3000)
N, K = map(int,input().split())
def comb(n,k):
    if n == 0:
        return 1
    if n < 0:
        return 0
    if k < 0:
        return 0
    if k == 0:
        return 1
    return comb(n-1,k-1) * n // k
R = N-K
MOD = 10**9+7
A = K-1
B = R-1
if N == K:
    print(1)
    for i in range(2, K+1):
        print(0)
else:
    for i in range(1, K+1):
        x = comb(A, i-1)
        y = comb(B, i-2)
        z = comb(B, i-1)
        w = comb(B, i)
        ans = x*(y+2*z+w)
        print(ans % MOD)

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N), L(N + 1), R(N + 1);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  L.at(0) = 0;
  for (int i = 0; i < N; i++) L.at(i + 1) = __gcd(L.at(i), A.at(i));
  R.at(N) = 0;
  for (int i = N - 1; i >= 0; i--) R.at(i) = __gcd(R.at(i + 1), A.at(i));
  int ans = 0;
  for (int i = 0; i < N; i++) ans = max(ans, __gcd(L.at(i), R.at(i + 1)));
  cout << ans << endl;
}

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

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

vector<int> g[100010];
int indeg[100010],len[100010],bef[100010];

int main(void){
	int N,M;
	cin >> N >> M;
	for(int i=1; i<=M; i++){
		int x,y;
		cin >> x >> y;
		x--;
		y--;
		g[x].push_back(y);
		indeg[y]++;
	}
	fill(bef, bef+N, -1);
	stack<int> s;
	for(int i=0; i<N; i++)
		if(indeg[i] == 0)
			s.push(i);
	while(s.size()){
		int p = s.top();
		s.pop();
		for(int to=0; to<g[p].size(); to++){
			if(len[p]+1 > len[g[p][to]]){
				len[g[p][to]] = len[p]+1;
				bef[g[p][to]] = p;
			}
			indeg[g[p][to]]--;
			if(indeg[g[p][to]] == 0)
				s.push(g[p][to]);
		}
	}
	cout<<*max_element(len, len+N) << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int x[92525], y[92525] ,s[92525];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int h, w, d, a, q, l, r;
	cin>>h>>w>>d;
	REP(i, h){
		REP(j, w){
			cin>>a;
			x[a]=i;
			y[a]=j;
		}
	}
	FOR(i, d+1, h*w+1){
		s[i]=s[i-d]+abs(x[i-d]-x[i])+abs(y[i-d]-y[i]);
	}
	cin>>q;
	REP(i, q){
		cin>>l>>r;
		cout<<s[r]-s[l]<<'\n';
	}
	return 0;
}


Measured memory_bytes: 2176
#include <stdlib.h>
#include <math.h>
#include <stdio.h>
#include <string.h>

int main()
{   int x;
    scanf("%d",&x);
    int n=x/100,z=x%100;
    if(n*5>=z){
        printf("1");
    }else{
        printf("0");
    }
    return 0;
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int a, b;
  cin >> a >> b;
  cout << (a * 3 + b) / 2 << endl;
  return 0;
}


Measured memory_bytes: 256
N,M,Q=map(int, input().split())
L=[[0]*(N+1) for _ in range(N+1)]
for i in range(M):
    l,r=map(int, input().split())
    L[l][r]+=1

#print(L)
for i in range(1,N+1):
    for j in range(1,N+1):
        L[i][j]+=L[i][j-1]+L[i-1][j]-L[i-1][j-1]

#print(L)

for i in range(Q):
    p,q=map(int, input().split())
    ans=L[q][q]-L[p-1][q]-L[q][p-1]+L[p-1][p-1]
    print(ans)

Measured memory_bytes: 13296
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int K = sc.nextInt();
        String S =sc.next();

        if(S.length()<= K) {
            System.out.println(S);
        } else {
            System.out.println(S.substring(0, K)+"...");
        }

    }
}

Measured memory_bytes: 27008
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e6 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

int n, eq[maxN], bg[maxN];
string st;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	cin >> st;
	n = st.size();
	reverse(st.begin(), st.end());
	bg[n] = 1;

	for(int i = n - 1; i >= 0; i--) {
		int elm = st[i] - '0';
		eq[i] = min(eq[i + 1] + elm, bg[i + 1] + 10 - elm);
		if(elm == 9)
			bg[i] = bg[i + 1];
		else bg[i] = min(eq[i + 1] + elm + 1, bg[i + 1] + 10 - (elm + 1));
	}

	cout << eq[0] << '\n';
}


Measured memory_bytes: 9116
#include<stdio.h>

int count100(int,int,int,int,int*);
int count50(int,int,int,int,int*);

int main(void){
    int A;
    int B;
    int C;
    int X;
    int i;
    int cnt=0;
    
    scanf("%d",&A);
    scanf("%d",&B);
    scanf("%d",&C);
    scanf("%d",&X);
    
    for(i=0;i<=A;i++){
        if(X>0){
            count100(i,B,C,X,&cnt);
        }
        else if(X==0){
            cnt++;
        }
        X=X-500;
    }
    
    printf("%d",cnt);
    return 0;
}

int count100(int A,int B,int C,int X,int *cnt){
    int i;
    
    for(i=0;i<=B;i++){
        if(X>0){
            count50(A,i,C,X,cnt);
        }
        else if(X==0){
            *cnt = *cnt+1;
        }
        X = X-100;
    }
    return 0;
}

int count50(int A,int B,int C,int X,int *cnt){
    int i;
    
    for(i=0;i<=C;i++){
        
        if(X==0){
            *cnt = *cnt+1;
        }
        else if(X<0){
            return 0;
        }
        X = X-50;
    }
    return 0;
}

Measured memory_bytes: 128
/// #RM
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
  vector<int >r;
  //set<int>::iterator it;
  int a,b,c; cin >> a >> b >> c; r.push_back(a); r.push_back(b); r.push_back(c); sort(r.begin(),r.end());
  cout << r[0] + r[1] << '\n';



}


Measured memory_bytes: 256
#pragma region header
#include <bits/stdc++.h>
#define int long long
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr int inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int n;cin >> n;
    cout << 10-n/200 << endl;
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    int h[N];
    for (int i=0; i<N; ++i) cin >> h[i];

    long long int dp[N];
    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);
    for (int i=0; i<N-2; ++i) dp[i+2] = min(dp[i+1]+abs(h[i+2]-h[i+1]), dp[i]+abs(h[i+2]-h[i]));

    cout << dp[N-1] << endl;

    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    int N; cin >> N;

    int lo = 1, hi = N+1;
    string s, u;
    cout << '?'; FOR(i,0,N-1) cout << ' ' << lo+i; cout << endl; cin >> s;
    while (hi-lo > 1) {
        int mid = (lo+hi)/2;
        cout << '?'; FOR(i,0,N-1) cout << ' ' << mid+i; cout << endl; cin >> u;
        if (u == s) lo = mid;
        else hi = mid;
    }

    char ans[2*N+1];
    int x = lo, y = lo+N;
    if (s == "Red") ans[x] = 'R', ans[y] = 'B';
    else ans[x] = 'B', ans[y] = 'R';

    FOR(i,1,2*N){
        if (i == x || i == y) continue;
        else if (i < x || i > y) { cout << '?'; FOR(j,x+1,y-1) cout << ' ' << j; }
        else { cout << '?'; FOR(j,1,x-1) cout << ' ' << j; FOR(j,y+1,2*N) cout << ' ' << j; }
        cout << ' ' << i << endl; cin >> u;
        ans[i] = (u == "Red" ? 'R' : 'B');
    }

    cout << "! ";
    FOR(i,1,2*N) cout << ans[i];
    cout << endl;
}



Measured memory_bytes: 724
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<bitset>
#define lson node<<1,st,mid
#define rson node<<1|1,mid+1,ed
#define mem(a,x) memset(a,x,sizeof(a))
#define me(a) memset(a,0,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define lowbit(x) x&(-x)
#define up(i,x,y) for(long long i=x;i<y;i++)
#define down(i,x,y) for(long long i=x;i>=y;i--)
#define in freopen("in.txt","r",stdin)
#define out freopen("out.txt","w",stdout)   
typedef long long ll;
const ll mod = 1e9+7;
const ll INF = 0x3f3f3f3f;
const ll maxn = 1e6 + 5;
const ll N=1e3+5;
const double pi = acos(-1.0);
const double eps=1e-9;
using namespace std;

int main(){
    int a,b;
    int k;
    cin>>k>>a>>b;
    bool flag=false;
    for(int i=1;i<=1000;i++){
        if(k*i>=a&&k*i<=b){
            flag=true;
            break;
        }
    }
    if(flag) cout<<"OK"<<endl;
    else cout<<"NG"<<endl;
}

Measured memory_bytes: 3136
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<long long>> VVLL;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) (a).begin(),(a).end()

const int MOD = 1000000007;

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

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

void debug(VI &arr){
	int n=arr.size();
	rep(i,n){
		cout<<arr.at(i)<<endl;
	}
}

void debug(VVI &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout << board.at(i).at(j) << " ";
		}
		cout<<endl;
	}
}

void debug(VVLL &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout<<board.at(i).at(j)<<" ";
		}
		cout<<endl;
	}
}

void debug(VS &board){
	int h = board.size();
	rep(i,h){
		cout<<board.at(i)<<endl;
	}
	return;
}

LL gcd(LL a,LL b){
	return b==0?a:gcd(b,a%b);
}

LL lcm(LL a,LL b){
	return a*b/gcd(a,b);
}

int main(){
	//cout<<fixed;
	//cout<<setprecision(9)<<...
	LL a,b,c,d;
	cin>>a>>b>>c>>d;
	LL e,f,g,h;
	e = a*c;
	f = a*d;
	g = b*c;
	h = b*d;
	VLL v = {e,f,g,h};
	sort(all(v));
	cout<<v[3]<<endl;
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cmath>
#include <map>
#include <set>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout<<#x<<": "<<x<<endl
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
 
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
int n,m,ans=0;
int a[60]={},b[60]={};
bool graph[60][60];
bool visited[60];

queue<int> q;
 
void dfs(int v){
    visited[v]=true;
    for(int v2=0; v2<n; v2++){
        if(graph[v][v2]==false)continue;
        if(visited[v2]==true)continue;
        dfs(v2);
    }
}

int main(){
    cin>>n>>m;
    for(int i=0; i<m; i++){
        cin>>a[i]>>b[i];
        a[i]--;b[i]--;
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }

    for(int i=0; i<m; i++){
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;
        for(int j=0; j<n; j++) visited[j]=false;

        dfs(0);

        bool bridge=false;
        for(int j=0; j<n; j++) if(visited[j]==false)bridge=true;
        if(bridge)ans+=1;
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define INF (1<<29)
signed main(){
	int n,k,x[100000],ans=INF;
	cin>>n>>k;
	rep(i,n)cin>>x[i];
	rep(i,n-k+1){
		if(x[i]==0)ans=min(ans,x[i+k-1]);
		else if(x[i+k-1]==0)ans=min(ans,abs(x[i]));
		else ans=min(ans,min(abs(x[i])+x[i+k-1]-x[i],abs(x[i+k-1])+x[i+k-1]-x[i]));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
def make_devisor(n):
    div_min = n+2
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            if i+n//i < div_min:
                div_min = i+n//i
    return div_min
n = int(input())
print(make_devisor(n)-2)

Measured memory_bytes: 2940