akhauriyash/Code-Regression huggingface dataset:
#include<bits//stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n;i++)
int main() {
	ll n, m, ans = 0,sum = 0,x,y;cin >> n >> m;
	vector<pair<ll, ll>> a(n);
	rep(i, n) {
		cin >> x >>  y;a[i] = make_pair(x, y);
	}
	sort(a.begin(), a.end());
	int i = 0;
	while (sum < m) {
		sum += a[i].second;
		ans += a[i].first * a[i].second;
		i++;
	}
	int u = sum - m;
	ans -= u * a[i - 1].first;
	cout << ans << endl;
}

Measured memory_bytes: 4736
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
 
int main(void)
{
    int n, t, a;
    scanf("%d %d %d", &n, &t, &a);
    int h[n];
    for (int i=0; i < n; i++) scanf("%d", &h[i]);
 
    double min = t - h[0]*0.006 - a;
    if (min < 0) min *= -1;
    double df;
    int num = 0;
 
    for (int i=1; i < n; i++){
        df = t - h[i]*0.006 - a;
        if (df < 0) df *= -1;
        if (df < min){
            min = df;
            num = i;
        }
    }
 
    printf("%d\n", num+1);
       return 0;
} 
 



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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 2e5;
int n, a[nsz + 5], rt, lst, ans;
int ql, qr, q[2 * nsz + 5];

struct treap {
	int sz, ls[nsz + 5], rs[nsz + 5], pri[nsz + 5];
	int key[nsz + 5], mn[nsz + 5], mx[nsz + 5];
	
	int inline node(int w) {
		int u = ++sz;
		key[u] = mn[u] = mx[u] = w, pri[u] = rand();
		return u;
	}
	
	void inline up(int u) {
		mn[u] = ls[u] ? mn[ls[u]] : key[u];
		mx[u] = rs[u] ? mx[rs[u]] : key[u];
	}
	
	int merge(int v1, int v2) {
		if (!v1 || !v2)  return v1 | v2;
		return pri[v1] < pri[v2] ? (rs[v1] = merge(rs[v1], v2), up(v1), v1) : (ls[v2] = merge(v1, ls[v2]), up(v2), v2);
	}
	
	void split(int u, int w, int &v1, int &v2) {
		if (!u) { v1 = v2 = 0; return; }
		key[u] <= w ? (v1 = u, split(rs[u], w, rs[u], v2), up(u)) : (v2 = u, split(ls[u], w, v1, ls[u]), up(u));
	}
	
	void inline push_back(int &rt, int w) { rt = merge(rt, node(w)); }
	
	void inline pop_back(int &rt, int w) { int v; split(rt, w - 1, rt, v); }
};
treap tr;

void inline init() {
	cont (i, n) {
		tr.push_back(q[qr], a[i]);
		if (i != n && a[i] > a[i + 1])  ++qr;
	}
	for (lst = n; tr.mx[q[qr]] == lst && lst; tr.pop_back(q[qr], lst--));
	
	++qr;
}

void inline deal() {
	for (++ans; !q[ql] && ql != qr; ++ql);
	int u = q[ql++], mx = tr.mx[u], v1, v2;
	for (int k = ql; k != qr && mx != lst; ++k) {
		if (!q[k])  continue;
		if (tr.mx[q[k]] > mx) {
			tr.split(q[k], mx, v1, v2);
			q[k] = v1, u = tr.merge(u, v2);
			mx = tr.mx[u];
		}
		int &r1 = q[k - 1], &r2 = q[k];
		if (r1 && tr.mx[r1] < tr.mn[r2])  r2 = tr.merge(r1, r2), r1 = 0;
	}
	int &r1 = q[qr - 1], &r2 = u;
	if (r1 && tr.mx[r1] < tr.mn[r2])  r2 = tr.merge(r1, r2), r1 = 0;
	for (; tr.mx[u] == lst && lst; tr.pop_back(u, lst--));
	q[qr++] = u;
}

int main() {
	scanf("%d", &n);
	cont (i, n) {
		scanf("%d", &a[i]);
	}
	for (init(); lst; deal());
	printf("%d\n", ans);
}

Measured memory_bytes: 7168
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
int main()
{
	int n, tmp;
	ll ans = 1;
	cin >> n;
	map<int, int> mp;
	rep(i, n) {
		cin >> tmp;
		mp[tmp]++;
	}
	for (auto elem : mp) {
		if (n % 2 == 1) {
			if (elem.first == 0) {
				if (elem.second != 1) {
					cout << 0 << endl; return 0;
				}
			}
			else if (elem.second != 2) {
				cout << 0 << endl; return 0;
			}
		}
		if (n % 2 == 0) {
			if (elem.second != 2) {
				cout << 0 << endl; return 0;
			}
		}
	}
	rep(i, n / 2) {
		ans *= ll(2);
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

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

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

    int acc = 0;
    for (int i=0;i<n-1;i++){
        for (int j=i+1;j<n;j++){
            acc += takoyaki[i] * takoyaki[j];
        }
    }
    cout << acc << endl;
    return 0;

}

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

int main(){
  string s;
  cin >> s;
  int ans = 0;
  for(int i = 0; i < 4; ++i){
    if(s[i] == '+'){
      ++ans;
    }
    if(s[i] == '-'){
      --ans;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, K;
	cin >> N >> K;
	VI P(N), A(N, 0);
	REP(i, N)cin >> P[i];

	FOR(i, 1, N) {
		if (P[i - 1] < P[i])A[i] = 1;
		A[i] += A[i - 1];
	}
	
	set<int>st;
	REP(i, K)st.insert(P[i]);

	bool cute = A[K - 1] == K - 1;
	int ans = !cute;

	REP(i, N - K) {
		bool ok = (*st.begin() == P[i]);
		st.erase(P[i]);
		st.insert(P[i + K]);
		ok &= (*st.rbegin() == P[i + K]);
		if (A[i + K] - A[i + 1] == K - 1) cute = true;
		else if (!ok)ans++;
	}





	cout << ans + cute << endl;
	return 0;
}



Measured memory_bytes: 12800
while true
    n, m = gets.chomp.split.map(&:to_i)
    break if [n, m] == [0, 0]
    map = []
    dice = []
    n.times{map << gets.to_i}
    m.times{dice << gets.to_i}
    pos = 0
    dice.each_with_index{|d, i|
        pos += dice[i]
        if pos >= n - 1
            puts i + 1
            break
        end
        pos += map[pos]
        if pos >= n - 1
            puts i + 1
            break
        end
    }
end 


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

int main(){
    string ans = "No";
    int a,b,c;
    cin >> a >> b >> c;
    int n = 0;
    if(a==b)n++;
    if(a==c)n++;
    if(b==c)n++;
    if(n==1)ans = "Yes";
    cout << ans << endl;
}

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

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) &= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int L;
  cin >> L;

  int n = 1, r = 0;
  while (n <= L) {
    n *= 2;
    r++;
  }
  if (n > L) r--;
  int N = r + 1;

  struct edge {
    int to, cost;
  };
  vector<vector<edge>> G(N + 1);

  int M = 2 * (N - 1);
  for (int i = 1; i < N; i++) {
    G[i].push_back({i + 1, 0LL});
    G[i].push_back({i + 1, bit(i - 1)});
  }

  for (int t = N - 1; t >= 1; t--) {
    if ((L - bit(t - 1)) >= (bit(r))) {
      G[t].push_back({N, L - bit(t - 1)});
      L -= bit(t - 1);
      M++;
    }
  }

  cout << N << " " << M << endl;
  for (int i = 1; i <= N; i++) {
    for (auto x : G[i]) {
      cout << i << " " << x.to << " " << x.cost << endl;
    }
  }
  return 0;
}


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

typedef pair<int, int> P;

int n, k;
int w[101][101];
bool visited[101];
int dist[101];
const int INF = 99999999;

int main()
{
    while(cin >> n >> k && n && k) {
        int a,b,c,d,e,t;
        
        for(int i = 1; i <= n; i++)
            fill(w[i], w[i] + 101, INF);
                
        for(int i = 0; i < k; i++) {
            cin >> t;
            if(t == 0) {
                cin >> a >> b;

                fill(visited, visited + 101, false);
                fill(dist, dist + 101, INF);
                priority_queue<P, vector<P>, greater<P> > que;
                que.push(P(0, a));
                while(!que.empty()) {
                    P p = que.top(); que.pop();
                    int v = p.second, cost = p.first;
                    if(visited[v])
                        continue;
                    
                    visited[v] = true;
                    dist[v] = cost;

                    if(v == b) {
                        cout << cost << endl;
                        break;
                    }
                    
                    for(int u = 1; u <= n; u++) {
                        if(dist[u] > dist[v] + w[v][u])
                            que.push(P(dist[v] + w[v][u], u));
                    }
                }
                if(!visited[b])
                    cout << -1 << endl;
                
            } else {
                cin >> c >> d >> e;
                w[c][d] = min(w[c][d], e);
                w[d][c] = w[c][d];
                
            }
        }
    }
}

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

#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'
typedef long long ll;

const double PI = acos(-1.0);
const int MOD = 1e9 + 7;
const ll MXN = 1e18;


int main(){
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   long double a, b;
   cin>>a>>b;
   ll ans = a*b;
   cout<<ans<<endl;

   return 0;
}

Measured memory_bytes: 3748
from fractions import gcd
from math import sqrt
a,s=map(int,input().split())
f=gcd(a,s)
ans=1
if f<=3:print(1+(f!=1));exit()
for i in range(2,int(sqrt(f))+1):

  if f%i==0:
    ans+=1
    while f%i==0:f//=i
print(ans+(f!=1))


Measured memory_bytes: 5044
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<cmath>
using namespace std;
typedef long long ll;
vector<int> pos[15];
int main(){
  ll l,r;
  cin>>l>>r;
  if((r-l+1>=2019)){
    cout<<0<<endl;
    return 0;
  }
  ll ans=2020;
  for(ll i=l;i<=r;i++){
    for(ll j=l;j<=r;j++){
      if(i<j){
        ans=min(ans,(i*j)%2019);
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
unsigned long long Fibonacci(unsigned long long m)
{
  static unsigned long long n1 = 0,n2 = 1;
  if(m == 0) return n2;
  n2 += n1 ^= n2 ^= n1 ^= n2;
  return Fibonacci(m - 1);
}
int main()
{
  unsigned long long i;
  scanf("%llu",&i);
  printf("%llu\n",Fibonacci(i));
  return 0;
}

Measured memory_bytes: 604
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>


#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#ifdef LOCAL
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)
#else
#define show(...)
#define showlr(n,l,r)
#endif

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

template<typename V,typename H> void resize(vector<V>& v,const H a){v.resize(a);}
template<typename V,typename H,typename... T> void resize(vector<V>& v,const H& a,const T... b){v.resize(a);for(auto &v:v) resize(v,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;
/*------------end of definitions------------*/

int N,X;
vi A;
int ans=1;

signed main(){

    in(N,X);
    A.resize(N);
    in(A);
    int tmp=0;
    rep(i,N){
        tmp+=A[i];
        if(tmp<=X){
            ans++;
        }
    }
    out(ans);


    return 0;
}


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

using namespace std;

int l[10];
int a, b;

int main()
{
	while (~scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&l[0],&l[1],&l[2],&l[3],&l[4],&l[5],&l[6],&l[7],&l[8],&l[9],&a,&b)) {
		for (int i = 1; i < 10; ++i) l[i] += l[i - 1];
		double c = (double)l[9] / (a + b) * a;
		for (int i = 0; i < 10; ++i) if (c <= l[i]) { printf("%d\n", i + 1); break; }
	}
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(),obj.end()
#define pb(obj) push_back(obj)
#define REP(i,N) for(ll i=0;i<N;i++)
typedef long long ll;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,L;
    cin>>N>>L;
    int num=(2*L+N-1)*N/2;
    if(L+N-1<0){cout<<num-(L+N-1)<<endl;}
    else if(0<L){cout<<num-L<<endl;}
    else{cout<<num<<endl;}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <time.h>
#include <queue>
#include <string.h>
#define sf scanf
#define pf printf
#define lf double
#define ll long long
#define p123 printf("123\n");
#define pn printf("\n");
#define pk printf(" ");
#define p(n) printf("%d",n);
#define pln(n) printf("%d\n",n);
#define s(n) scanf("%d",&n);
#define ss(n) scanf("%s",n);
#define ps(n) printf("%s",n);
#define sld(n) scanf("%lld",&n);
#define pld(n) printf("%lld",n);
#define slf(n) scanf("%lf",&n);
#define plf(n) printf("%lf",n);
#define sc(n) scanf("%c",&n);
#define pc(n) printf("%c",n);
#define gc getchar();
#define re(n,a) memset(n,a,sizeof(n));
#define len(a) strlen(a)
#define LL long long
#define eps 1e-6
using namespace std;
int main() {
    int n = 0;
    s(n);
    if(n == 24){
        puts("Christmas Eve");
    }else if(n == 23){
        puts("Christmas Eve Eve");
    }else if(n == 25){
        puts("Christmas");
    }else if(n == 22){
        puts("Christmas Eve Eve Eve");
    }

    return 0;
}

    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int,int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1LL<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1LL<<(i))))
#define setbit1(n,i) ((n)|(1LL<<(i)))
#define togglebit(n,i) ((n)^(1LL<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define fi first
#define se second
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d%d",&a,&b)
#define PI (acos(-1))
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD (1000000007)
#define asz 500005
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define pf push_front
ll cnt[500005];
int main(){
    fastread;
    ll n,i,j,k,l,m;
    cin>>n;
    for(i=1;i<n;i++){
        ///cin>>a[i];
        cin>>k;
        cnt[k]++;
    }
    for(i=1;i<=n;i++)
        cout<<cnt[i]<<"\n";
}

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

using namespace std;

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

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

int w, h;
int xs, ys;
int xg, yg;
int maze[102][102];

using P = pair<int, int>;
void solve() {
    int c = maze[ys][xs];
    queue<P> que;
    que.push(P(ys, xs));
    set<P> visited;
    visited.insert(P(ys, xs));
    bool ok = false;
    while (que.size()) {
        auto p = que.front();
        que.pop();
        int y = p.first;
        int x = p.second;
        if (yg == y && xg == x) ok = true;
        rep(k, 4) {
            int ny = y + dy[k];
            int nx = x + dx[k];
            if (ny < 0 || nx < 0) continue;
            if (h <= ny || w <= nx) continue;
            if (maze[ny][nx] != c) continue;
            if (visited.count(P(ny, nx))) continue;
            visited.insert(P(ny, nx));
            que.push(P(ny, nx));
        }
    }
    cout << (ok ? "OK" : "NG") << endl;
}

int main() {
    while (cin >> w >> h, w) {
        rep(i, 102) rep(j, 102) maze[i][j] = -1;
        cin >> xs >> ys;
        cin >> xg >> yg;
        xs--, ys--;
        xg--, yg--;
        int n;
        cin >> n;
        rep(_, n) {
            int c, d, x, y;
            cin >> c >> d >> x >> y;
            x--, y--;
            if (d == 0) {
                rep(i, 2) rep(j, 4) maze[y + i][x + j] = c;
            } else {
                rep(i, 4) rep(j, 2) maze[y + i][x + j] = c;
            }
        }
        solve();
    }

    return 0;
}

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

const int MAXN = 10010;
const int MAXD = 110;
const int MAXC = 11;
const int MOD = 1000 * 1000 * 1000 + 7;
int nbCombi[MAXN][MAXD][MAXC];
int32_t main()
{
	string K;
	cin >> K;
	int D;
	cin >> D;
	nbCombi[0][0][0] = 1;
	for (int iNombre = 1 ; iNombre <= (int)K.size() ; iNombre++)
	{
		for (int iMod = 0 ; iMod < D ; iMod++)
		{
			for (int iC = 0 ; iC < 10 ; iC++)
			{
				for (int iPrec = 0 ; iPrec < 10 ; iPrec++)
				{
					nbCombi[iNombre][iMod][iC] =(nbCombi[iNombre][iMod][iC] +  nbCombi[iNombre - 1][((iMod - iC) % D + D)  % D][iPrec]) % MOD;	
				}
			}
		}
	}
	int nbReponses = 0;
	int resteActuel = 0;
	for (int iPos = K.size()  ; iPos > 0 ; iPos--)
	{
		int stop = (K[K.size() - iPos] - '0');
		if (iPos == 1) stop++;
		for (int j = 0 ; j <stop ; j++)
		{
			nbReponses =(nbReponses +  nbCombi[iPos][(D - resteActuel) % D][j]) % MOD ;
		}

		resteActuel = (resteActuel + (K[K.size() - iPos] - '0')) % D;
	}
	cout<<(nbReponses - 1 + MOD) % MOD<<endl;
	return 0;
}

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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];

    int a_sum = accumulate(a.begin(), a.end(), 0);

    vector<int> divisor;
    for (int i = 1; i*i <= a_sum; i++)
    if (a_sum % i == 0)
    {
        divisor.push_back(i);
        divisor.push_back(a_sum/i);
    }
    sort(divisor.rbegin(), divisor.rend());

    for (auto div: divisor)
    {
        vector<int> res;
        rep(j, 0, n)
        if (a[j] % div != 0)
            res.push_back(a[j] % div);
        sort(res.begin(), res.end());

        ll c;
        if (res.size() > 0)
        {
            ll rsize = res.size();
            vector<ll> cumres(rsize + 1);
            cumres[0] = 0;
            rep(j, 0, rsize) cumres[j + 1] = cumres[j] + res[j];

            c = cumres[rsize - 1];
            rep(j, 1, rsize)
            {
                ll s1, s2;
                s1 = cumres[j];
                s2 = div * (rsize-j) - (cumres[rsize] - cumres[j]);
                c = min(c, max(s1, s2));
            }
        }
        else c = 0;
        if (c <= k)
        {
            cout << div << endl;
            break;
        }
    }
    return 0;
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
Int mod = 1e9+7;
//Int mod = 998244353;

typedef struct {
    double y, x;
} p_t;

int main() {
    Int n;
    cin >> n;
    vector<Int> v(n);
    for (Int i = 0; i < n; i++) {
        cin >> v[i];
    }
    Int res = 1;
    Int mi = v[0];
    for (Int i = 1; i < n; i++) {
        if (mi > v[i]) {
            res++;
        }
        mi = min(mi, v[i]);
    }
    dump(res);
    return 0;
}


Measured memory_bytes: 1792
using System;

namespace B___Not_Found
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var a = "abcdefghijklmnopqrstuvwxyz";
            for(var i=0; i<s.Length; i++)
            {
                a = a.Replace(s[i].ToString(), "");
            }
            if(a=="")
            {
                Console.WriteLine("None");
            }
            else
            {
                Console.WriteLine(a[0]);
            }
        }
    }
}

Measured memory_bytes: 13280
#include<bits/stdc++.h>
using namespace std;
int dp[100005][3];
int a[100005][3];
int main()
{
	int n;cin>>n;
	for(int i=1;i<=n;i++)
	{
		for(int k=1;k<=3;k++) 
            {
                cin>>a[i][k];
            }
	}
    for(int i=1;i<=3;i++) dp[1][i] = a[1][i];
    for(int i=1;i<=n;i++)
    {
    	for(int k=1;k<=3;k++)
    	{
    		if(k==1)
    		{
    			dp[i+1][k+1] = max(dp[i+1][k+1],dp[i][k]+a[i+1][k+1]);
    			dp[i+1][k+2] = max(dp[i+1][k+2],dp[i][k]+a[i+1][k+2]);
    		}
    		else if(k==2)
    		{
    			dp[i+1][k-1] = max(dp[i+1][k-1],dp[i][k]+a[i+1][k-1]);
    			dp[i+1][k+1] = max(dp[i+1][k+1],dp[i][k]+a[i+1][k+1]);
    		}
    		else
    		{
    			dp[i+1][k-1] = max(dp[i+1][k-1],dp[i][k]+a[i+1][k-1]);
    			dp[i+1][k-2] = max(dp[i+1][k-2],dp[i][k]+a[i+1][k-2]);
    		}
    	}
    }
    	int ans = -1;
    	for(int i=1;i<=3;i++)
    	{
            ans = max(ans,dp[n][i]);
        }
    	cout<<ans<<endl;
  return 0;  
}

Measured memory_bytes: 2560
def is_even(u):
    return u % 2 == 0


n = int(input())
a = list(map(int, input().split()))

adash = []
for i in range(n):
    adash.append(a[i] - (i+1))

a_sorted = sorted(adash)


if is_even(n):
    b = a_sorted[n//2]
else:
    b = a_sorted[(n-1)//2]
ans = 0
for i in range(n):
    ans += abs(adash[i] - b)
print(ans)


Measured memory_bytes: 26180
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

#define Int register int
#define int long long
#define MAXN 10000005

int Abs (int x){return x > 0 ? x : -x;}

int tot;
int prime[MAXN];

bool vis[MAXN];

void Prime (int n)
{
	vis[1] = 1;
	for (Int i = 2;i <= n;++ i)
	{
		if (!vis[i]) prime[++ tot] = i;
		for (Int j = 1;j <= tot && i * prime[j] <= n;++ j)
		{
			vis[i * prime[j]] = 1;
			if (i % prime[j] == 0) break;
		}
	}
}

bool check (int x){return !vis[x];}

bool rev[MAXN];

int read ()
{
	int x = 0;char c = getchar();int f = 1;
	while (c < '0' || c > '9'){if (c == '-') f = -f;c = getchar();}
	while (c >= '0' && c <= '9'){x = (x << 3) + (x << 1) + c - '0';c = getchar();}
	return x * f;
}

void write (int x)
{
	if (x < 0){x = -x;putchar ('-');}
	if (x > 9) write (x / 10);
	putchar (x % 10 + '0');
}

vector <int> s1,s2;

struct edge
{
	int v,nxt;
}e[MAXN << 1];

int top = 1;
int head[MAXN];

void Add_Edge (int u,int v)
{
	e[++ top] = edge {v,head[u]};
	head[u] = top;
}

int my[MAXN];
bool visit[MAXN];

int dfs (int u)
{
	for (Int i = head[u];i;i = e[i].nxt)
	{
		int v = e[i].v;
		if (visit[v]) continue;
		visit[v] = 1;
		if (my[v] == -1 || dfs (my[v]))
		{
			my[v] = u;
			return 1;
		}
	}
	return 0;
}

int Hungry ()
{
	int cnt = 0;
	memset (my,-1,sizeof (my));
	for (Int i = 0;i < s1.size();++ i)
	{
		memset (visit,0,sizeof (visit));
		cnt += dfs (i);
	}
	return cnt;
}

signed main()
{
	int n = read ();
	int Maxn = 0;
	for (Int i = 1;i <= n;++ i)
	{
		int x = read ();
		rev[x] ^= 1;
		Maxn = max (Maxn,x + 1);
	}
	Prime (Maxn);
	for (Int i = 1;i <= Maxn;++ i)
		if (rev[i] != rev[i - 1])
			if (i & 1)
				s1.push_back(i);
			else 
				s2.push_back(i);
	for (Int i = 0;i < s1.size();++ i)
		for (Int j = 0;j < s2.size();++ j)
			if (check (Abs (s1[i] - s2[j])))
				Add_Edge (i,j);
	int Ans = Hungry ();
	write (Ans + (s1.size() - Ans) / 2 * 2 + (s2.size() - Ans) / 2 * 2 + (s1.size() - Ans) % 2 * 3),putchar ('\n'); 
	return 0; 
}

Measured memory_bytes: 116992
n = gets.to_i
a = gets.split.map(&:to_i)
c = 0
z = false
a.each do |i|
    c += 1 if i < 0
    z = true if i == 0
end
n.times do |i|
    a[i] *= -1 if a[i] < 0
end
a.sort!
a[0] *= -1 if c%2 == 1 && !z
puts a.inject(:+)

Measured memory_bytes: 9464
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

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

    return 0;
}

Measured memory_bytes: 896
text = input()

a = int(text.split(' ')[0])
b = int(text.split(' ')[1])
k = int(text.split(' ')[2])

t = min(a + k, b + 1)
for i in range(a, t):
    print(i)

if max(b - k + 1, t) < b + 1:
    for i in range(max(b - k + 1, t), b + 1):
        print(i)


Measured memory_bytes: 3064
li = [int(input()) for _ in range(5)]  # li = ['hoge', 'bar', 'foo']
minx = 10000
for i in range(5):
    tmp = 0
    for j in range(5):
        if i == j:
            tmp += li[j]
        else:
            if li[j] % 10 == 0:
                tmp += li[j]
            else:
                tmp += (li[j] // 10 + 1) * 10
    if tmp < minx:
        minx = tmp
print(minx)

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

int main() {
	int N;
	cin >> N;
	
	vector<int> t(N + 1);
	vector<int> x(N + 1);
	vector<int> y(N + 1);
	
	for (int i = 0; i < N; ++i) cin >> t.at(i + 1) >> x.at(i + 1) >> y.at(i + 1);
	
	bool can = true;
	for (int i = 0; i < N; ++i) {
		int dt = t.at(i + 1) - t.at(i);
		int dist = abs(x.at(i + 1) - x.at(i)) + abs(y.at(i + 1) - y.at(i));
		if (dt < dist) can = false;
		if (dt % 2 != dist % 2) can = false;
	}
	
	if (can) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
typedef pair<string, P> PP;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<PP> d(n);
    rep(i, 0, n){
        string s;
        int p;
        cin >> s >> p;
        d[i] = PP(s, P(-p, i));
    }
    sort(d.begin(), d.end());
    rep(i, 0, n){
        cout << d[i].second.second + 1 << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card {
  char suit;
  int value;
};

struct Card L[MAX/2+2], R[MAX/2+2];

void merge(struct Card A[], int n, int left, int mid, int right) {
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  for(i=0;i<n1;i++) L[i] = A[left + i];
  for(i=0;i<n2;i++) R[i] = A[mid  + i];
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;
  for(k=left; k<right; k++) {
    if(L[i].value <= R[j].value) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(struct Card A[], int n, int left, int right) {
  if(left+1 < right) {
    int mid = (left+right) / 2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid, right);
    merge(A,n,left,mid,right);
  }
}

int partition(struct Card A[], int n, int p, int r) {
  int i, j;
  struct Card t, x;
  x = A[r];
  i = p-1;
  for(j=p; j<r; j++) {
    if(A[j].value <= x.value) {
      i++;
      t=A[i]; A[i]=A[j]; A[j]=t;
    }
  }
  t=A[i+1]; A[i+1]=A[r]; A[r]=t;
  return i+1;
}

void quickSort(struct Card A[], int n, int p, int r) {
  int q;
  if(p<r) {
    q = partition(A,n,p,r);
    quickSort(A,n,p,q-1);
    quickSort(A,n,q+1,r);
  }
}

int main() {
  int n, i, v;
  struct Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;

  scanf("%d", &n);

  for(i=0;i<n;i++) {
    scanf("%s %d",S,&v);
    A[i].suit =  B[i].suit  = S[0];
    A[i].value = B[i].value = v;
  }

  mergeSort(A,n,0,n);
  quickSort(B,n,0,n-1);

  for(i=0;i<n;i++) {
    if(A[i].suit != B[i].suit) stable = 0;
  }

  if(stable==1) printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++) {
    printf("%c %d\n",B[i].suit,B[i].value);
  }

  return 0;
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int n,offset=100010;
vector<vector<int>> g(300010);
vector<bool> used(300010,false);
vector<ll> cnt(2);

void dfs(int v){
	if(used[v]) return;
	used[v]=true;
	if(v>=offset) cnt[1]++;
	else cnt[0]++;
	for(auto itr:g[v]){
		dfs(itr);
	}
} 

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin>>n;
	vector<int> ten;
	rep(i,n){
		int x,y;
		cin>>x>>y;
		y+=offset;
		ten.push_back(x);
		ten.push_back(y);
		g[x].push_back(y);
		g[y].push_back(x);
	}
	ll ans=0;
	for(auto itr:ten){
		if(used[itr]) continue;
		rep(j,2) cnt[j]=0;
		dfs(itr);
		ans+=cnt[0]*cnt[1];
	}
	ans-=n;
	cout<<ans<<endl;
}

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

int judge[4];
int input[5];

int main(){
	while(cin >> input[0], input[0]){
		for(int i=0; i < 4; i++) judge[i] = 0;
		judge[input[0]] = 1;
		for(int i=1; i < 5; i++){
			cin >> input[i];
			judge[input[i]] = 1;
		}

		if(judge[1] && judge[2] && judge[3]) for(int i=0; i < 5; i++) cout << '3' << endl;
		else if(judge[1] && judge[2]){
			for(int i=0; i < 5; i++){
				if(input[i] == 1) cout << '1' << endl;
				else cout << '2' << endl;
			}
		}
		else if(judge[2] && judge[3]){
			for(int i=0; i < 5; i++){
				if(input[i] == 2) cout << '1' << endl;
				else cout << '2' << endl;
			}
		}
		else if(judge[1] && judge[3]){
			for(int i=0; i < 5; i++){
				if(input[i] == 3) cout << '1' << endl;
				else cout << '2' << endl;
			}
		}
		else {
			for(int i=0; i < 5; i++){
				cout << '3' << endl;
			}
		}
	}
}

Measured memory_bytes: 1152
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    int N;
    cin>>N;
    int ans=0;
    for(int i=1;i<=N;i++){
        if(1<=i&&i<=9)ans++;
        if(100<=i&&i<=999)ans++;
        if(10000<=i&&i<=99999)ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define tcase int _; cin >> _; while(_--)
const int MAX = 1e6;

int n, m, k;
ll a[MAX], b[MAX];
int ans;

void solve() {
	cin >> n >> m >> k;
	a[0] = b[0] = 0;
	for(int i=1; i<=n; i++) {
		cin >> a[i];
		a[i]+=a[i-1];
	}
	for(int i=1; i<=m; i++) {
		cin >> b[i]; 
		b[i]+=b[i-1];
	}
	ans = 0;
	int j=m;
	for(int i=0; i<=n; i++) {
		if(a[i] > k) break;
		for(; a[i]+b[j]>k; j--);
		ans = max(ans, i+j);
		
	}		
	cout << ans << "\n";
}

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

 	solve();

  	return 0;
}



Measured memory_bytes: 6756
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//                                                                              NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first 
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define LINF 98765432123456789
#define testcases() ll t; cin>>t; while(t--)
#define debug cout<<"Hello\n";
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define debug4(w,x,y,z) cout<<#w<<" "<<w<<" "<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
#define sz(x) (ll)((x).size())
#define all(x) (x).begin(),(x).end()
//----------------------------------------------------------------------------------------------------------------------------------------------------

vector<vector<int>> g;
vector<bool> visited;
vector<int> ans;
void bfs(int u=1)
{
	queue<pair<int,int>> q;
	q.push({u,0});
	while(!q.empty())
	{
		pair<int,int> p = q.front();
		q.pop();
		for(auto it: g[p.fi])
		{
			if(visited[it])
				continue;
			ans[it] = p.fi;
			q.push({it,p.se+1});
			visited[it]=true;
		}
	}
}
int main()
{
	fast;
	int n,m,u,v;
	cin>>n>>m;
	g.resize(n+5);
	ans.resize(n+5);
	visited.resize(n+5,false);
	for(int i=0;i<m;i++)
	{
		cin>>u>>v;
		g[u].pb(v);
		g[v].pb(u);
	}
	bfs();
	bool ok = true;
	for(int i=1;ok && i<=n;i++)
		if(!visited[i])
			ok = false;
	if(!ok)
		cout<<"No";
	else
	{
		cout<<"Yes\n";
		for(int i=2;i<=n;i++)
			cout<<ans[i]<<"\n";
	}
	return 0;
}


Measured memory_bytes: 10396
package main
import (
    "fmt"
    "strings"
    "math"
)
    
func main(){
    var N int
    fmt.Scan(&N)
    str := ""
    front, back, double, ans := 0.0, 0.0, 0, 0
    for i:=0;i<N;i++{
        fmt.Scan(&str)
        if str[0]=='B' && str[len(str)-1] == 'A'{
            double++
        }else if str[0]=='B'{
            front++
        }else if str[len(str)-1] == 'A'{
            back++
        }
        ans += strings.Count(str, "AB") 
    }
    if front==0&&back==0&&double!=0{
        double --
    }
    fmt.Println(ans+int(math.Min(front, back)) +double)
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  int x;
  cin >> x;
  cout << x/3 << endl;
  return 0;
}

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

using namespace std;
#define ll long long

bool p(int n) {
    for (int i = 2; i * i <= n; i++) if (n % i == 0)return 0;
    return 1;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int x;
    cin >> x;
    for (int i = x;; i++) {
        if (p(i)) return cout << i << endl, 0;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int a, b, c, d; cin >> a >> b >> c >> d;
  if (abs(a-c) <= d) cout << "Yes" << endl;
  else if (max(abs(a-b), abs(b-c)) > d) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}

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

int n,x,a[105];
int main(){
	cin>>n>>x;
	for(int i=1;i<=n;++i)cin>>a[i];
	sort(a+1,a+n+1);
	int ans=0;
	for(int i=1;i<n;++i){
		if(x<a[i])break;
		++ans;x-=a[i];
	}
	if(x==a[n])++ans;
	cout<<ans<<'\n';
	
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

signed main()
{
  string s, t;
  cin >> s >> t;
  sort(ALL(s));
  sort(rbegin(t), rend(t));

  if (s < t) {
    puts("Yes");
  } else puts("No");

  return 0;
}



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

int main(){
	int a,b;
	cin>>a>>b;
	if(a%3==0 || b%3==0){
		cout<<"Possible"<<endl;
		return 0;
	}
	else if((a+b)%3==0){
		cout<<"Possible"<<endl;
		return 0;
	}
	else cout<<"Impossible"<<endl;
}

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

int main() {
  long ans=999999;
  string s,t;
  cin >> s >> t;
  for(long i=0;i<=s.size()-t.size();i++) {
    long a=0;
    for(long j=0;j<t.size();j++) {
      if(s[i+j]!=t[j]) a++;
    }
    ans=min(ans,a);
  }
  cout << ans << endl;
}

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

using namespace std;

int main()
{
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
	cout.precision(10);
	int n;
	cin >>n;
	vector< vector<double> > dp(n+1,vector<double>(n+1));
	vector<double> v(n+1);
	for(int i = 1;i<=n;i++) cin >>v[i];
	dp[0][0]=1.0;
	for(int i = 1;i<=n;i++) {
		 dp[i][0] = dp[i-1][0]*(1-v[i]);
		 for(int j = 1;j<=i;j++) {
		 	dp[i][j] = dp[i-1][j-1]*v[i] +dp[i-1][j]*(1-v[i]);
		 }
	}
	double ans = 0.0;
	for(int i = (n+1)/2;i<=n;i++) ans = ans + dp[n][i];
	cout<<ans<<'\n';  
	return 0;
}

Measured memory_bytes: 74164
import java.util.Scanner;

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

		long sumAll = 0;
		long[] sums = new long[n];
		for (int i = 0; i < n; i++ ) {
			sumAll += sc.nextLong();
			sums[i] = sumAll;
		}

		long minDif = Long.MAX_VALUE;
		for (int i = 0; i < n; i++) {
			long dif = Math.abs(sumAll - sums[i] * 2);
			if (dif < minDif) {
				minDif = dif;
			}
		}
		System.out.println(minDif);
		sc.close();
	}
}


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

#define ll long long
#define ld long double

int n;
int a[100001][3], dp[100001][3];

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

    cin >> n;
    for(int i=0;i<n;i++) {
        for(int j=0;j<3;j++) {
            cin >> a[i][j];
            dp[i][j] = 0;
        }
    }

    for(int i=0;i<n;i++) {
        dp[i+1][0] = a[i][0] + max(dp[i][1], dp[i][2]);
        dp[i+1][1] = a[i][1] + max(dp[i][0], dp[i][2]);
        dp[i+1][2] = a[i][2] + max(dp[i][0], dp[i][1]);

    }

    cout << max(dp[n][0], max(dp[n][1], dp[n][2]));
    return 0;
}


Measured memory_bytes: 2560
#include <cstdio>
int min(int a,int b){
	return a<b?a:b;
}
const int Maxn=100000;
const int Inf=(1<<30);
int n,m,q;
int a[Maxn+5],b[Maxn+5];
int main(){
	int x,y,c;
	scanf("%d%d%d",&n,&m,&q);
	int minn_a=Inf,minn_b=Inf;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		minn_a=min(minn_a,a[i]);
	}
	for(int i=1;i<=m;i++){
		scanf("%d",&b[i]);
		minn_b=min(minn_b,b[i]);
	}
	int ans=minn_a+minn_b;
	for(int i=1;i<=q;i++){
		scanf("%d%d%d",&x,&y,&c);
		ans=min(ans,a[x]+b[y]-c);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(void)

{

int a,b,d,r ;

double f ;

scanf("%d",&a) ;

scanf("%d",&b) ;

d = a/b ;

r = a%b ;

f = (double)a/b ;

printf("%d %d %.5lf",d,r,f) ;

return 0 ;

}

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

#define I inline
#define fi first
#define se second
#define R register
#define LL long long
#define mp make_pair
#define reg register int
#define pii pair<int,int>
#define fo(i, a, b) for(reg i = a; i <= b; i++)
#define fd(i, a, b) for(reg i = a; i >= b; i--)
#define bp __builtin_popcount
#define vi vector<int>
#define cr const reg&
#define int128 __int128
using namespace std;
const int mod = 998244353, N = 1e6 + 1;

I int _max(cr x, cr y) {return x > y ? x : y;}
I int _min(cr x, cr y) {return x < y ? x : y;}
I int128 read() {
	int128 x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
	return x * f;
}
I void ptt(int128 x) {if(x >= 10) ptt(x / 10); putchar(x % 10 + '0');}
I void put(int128 x) {x < 0 ? putchar('-'), ptt(-x) : ptt(x);}
I void pr1(int128 x) {put(x), putchar(' ');}
I void pr2(int128 x) {put(x), puts("");}

I int pow_mod(reg a, reg k) {reg ans = 1; for(; k; k >>= 1, a = (LL)a * a % mod) if(k & 1) ans = (LL)ans * a % mod; return ans;}

map<int128, int128> f;
LL A, B, C, D;

I int128 dfs(int128 n) {
	if(!n) return 0;
	if(n == 1) return D;
	if(f.count(n)) return f[n];
	int128 ans = D * n;
	reg o = n % 2;
	if(!o) ans = min(ans, dfs(n / 2) + A);
	else ans = min(ans, min(dfs((n - 1) / 2), dfs((n + 1) / 2)) + A + D);
	o = n % 3;
	if(o <= 1) ans = min(ans, dfs((n - o) / 3) + B + D * o);
	else ans = min(ans, dfs((n + 3 - o) / 3) + B + (3 - o) * D);
	o = n % 5;
	if(o <= 2) ans = min(ans, dfs((n - o) / 5) + C + D * o);
	else ans = min(ans, dfs((n - o + 5) / 5) + C + D * (5 - o));
	return f[n] = ans;
}

int main() {
	reg T = read();
	while(T--) {
		int128 n = read(); A = read(), B = read(), C = read(), D = read();
		f.clear(), pr2(dfs(n));
	}
	return 0;
}




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

namespace TYC
{
	typedef long long ll;
	const int N = 3005, mod = 1e9 + 7, INV2 = (mod + 1) >> 1;

	int n, q, A[N], F[N][N], G[N][N];

	inline int read()
	{
		int x = 0, f = 0, ch = getchar();
		while (!isdigit(ch))
			f |= (ch == '-'), ch = getchar();
		while (isdigit(ch))
			x = x * 10 + ch - '0', ch = getchar();
		return f ? -x : x;
	}

	void work()
	{
		scanf("%d%d", &n, &q);
		for (int i = 1; i <= n; i++)
			A[i] = read();
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= n; j++)
				F[i][j] = A[i] > A[j];
		int ans = 0, tmp = 1;
		while (q--)
		{
			tmp = (tmp << 1) % mod;
			int x = read(), y = read();
			for (int i = 1; i <= n; i++)
				G[i][x] = F[i][x], G[i][y] = F[i][y];
			for (int i = 1; i <= n; i++)
				G[x][i] = F[x][i], G[y][i] = F[y][i];
			for (int i = 1; i <= n; i++)
				if (i != x && i != y)
				{
					F[x][i] = F[y][i] = int((ll)(G[x][i] + G[y][i]) * INV2 % mod);
					F[i][x] = F[i][y] = int((ll)(G[i][x] + G[i][y]) * INV2 % mod);
				}
			F[x][y] = F[y][x] = int((ll)(G[x][y] + G[y][x]) * INV2 % mod);
		}
		for (int i = 1; i <= n; i++)
			for (int j = i + 1; j <= n; j++)
				ans = int((ans + (ll)F[i][j] * tmp) % mod);
		printf("%d\n", ans);
	}
}

int main()
{
	TYC::work();
	return 0;
}

Measured memory_bytes: 70784
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define pb(a) push_back(a)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
using namespace std;

void order(int d[6], string str){
    int temp;
    if(str == "North"){
        temp = d[2];
        d[2] = d[4];
        d[4] = d[5];
        d[5] = d[0];
        d[0] = temp;
    }else if(str == "East"){
        temp = d[2];
        d[2] = d[1];
        d[1] = d[5];
        d[5] = d[3];
        d[3] = temp;
    }else if(str == "West"){
        temp = d[2];
        d[2] = d[3];
        d[3] = d[5];
        d[5] = d[1];
        d[1] = temp;
    }else if(str == "South"){
        temp = d[2];
        d[2] = d[0];
        d[0] = d[5];
        d[5] = d[4];
        d[4] = temp;
    }else if(str == "Right"){
        temp = d[0];
        d[0] = d[1];
        d[1] = d[4];
        d[4] = d[3];
        d[3] = temp;
    }else{
        temp = d[0];
        d[0] = d[3];
        d[3] = d[4];
        d[4] = d[1];
        d[1] = temp;
    }
}

int main(){
    int n;
    while(cin >> n){
       int d[6] = {5,4,1,3,2,6}, sum = 0;
       rep(i,n){
           string str;
           cin >> str;
           order(d, str);
           sum+=d[2];
       }
       if(n)
       cout << sum + 1 << endl;
    }
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
#include<map>
using namespace std;
typedef long long int lli;
typedef long long ll;
#define mod 10000000007
int main()
{
  ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
  lli n,i,k=0;
  cin>>n;
  map<string,int> mp;
  for(i=0;i<n;i++)
  {
      string s;
      cin>>s;
      mp[s]++;
  }
  for(auto it=mp.begin();it!=mp.end();it++)
  {
      k++;
  }
  cout<<k<<"\n";
}

Measured memory_bytes: 19060