akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int MOD2 = 1007681537;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
#define db(x) cerr << #x << " = " << (x) << " ";
#define endln cerr << "\n";

const int maxn = 1e5 + 5;
int n;
int a[maxn];

void solve() {
    cin >> n;
    map<int, int> hs;
    FOR(i, 0, n) {
        int x; cin >> x;
        while (x % 2 == 0) a[i]++, x /= 2;
        chkmin(a[i], 2);
        hs[a[i]]++;
    }
    if (hs[0] > hs[2] + 1) {
        cout << "No\n";
        return;
    }
    if (hs[0] == hs[2] + 1) {
        if (hs[1]) {
            cout << "No\n";
            return;
        }
    }
    cout << "Yes\n";
}

int main() {
    int JUDGE_ONLINE = 1;
    if (fopen("in.txt", "r")) {
        JUDGE_ONLINE = 0;
        assert(freopen("in.txt", "r", stdin));
        //assert(freopen("out.txt", "w", stdout));
    }
    else {
        ios_base::sync_with_stdio(0), cin.tie(0);
    }
    solve();
    if (!JUDGE_ONLINE) {
        //cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    }
    return 0;
}

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

typedef long long ll;
typedef long long ld;
typedef vector<int> vi;
typedef priority_queue<int> pq;
typedef pair<ll, ll> pii;

struct Node
{
    int node, len;
    Node() {node = len = 0;}
    Node(int node, int len) {this -> node = node, this -> len = len;}
};
typedef vector<Node> vg;

#define MAX 1000001
#define NON 0
#define MOD 1000000007

#define FOR(type, i, a, b) for(type i = a; i <= b; i++)
#define FORR(type, i, b, a) for(type i = b; i >= a; i--)

#define testBit(n, bit) ((n >> bit) & 1)
#define flipBit(n, bit) (n ^ (1ll << bit))
#define randomize mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s, t; cin >> s >> t;
    bool ok = false;
    if (t.length() == s.length() + 1){
        ok = true;
        FOR(int, i, 0, s.length() - 1)
            if (s[i] != t[i]) ok = false;
    }
    if (ok) cout << "Yes"; else cout << "No";
}

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

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

using namespace std;

int main(){
	int h,w,n; scanf("%d%d%d",&h,&w,&n);
	vector<pair<int,int>> a;
	rep(i,n){
		int x1,y1,x2,y2; scanf("%d%d%d%d",&y1,&x1,&y2,&x2);
		if((x1==0 || x1==w || y1==0 || y1==h)
		&& (x2==0 || x2==w || y2==0 || y2==h)){
			auto add=[&](int x,int y){
				if     (y==0) a.emplace_back(x,i);
				else if(x==w) a.emplace_back(w+y,i);
				else if(y==h) a.emplace_back(w+h+(w-x),i);
				else          a.emplace_back(w+h+w+(h-y),i);
			};
			add(x1,y1);
			add(x2,y2);
		}
	}

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

	stack<int> S;
	for(auto x:a){
		int i=x.second;
		if(S.empty() || S.top()!=i) S.push(i);
		else S.pop();
	}
	puts(S.empty()?"YES":"NO");

	return 0;
}


Measured memory_bytes: 2420
#include <iostream>
using namespace std;
int main()
{
    int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin>>k;
    cout<<a[k-1];
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int n, m, l[3009], r[3009], p[3009], dp[3009][3009], R, s[3009], t[3009], mod = 1000000007; bool used[3009]; string S;
int main() {
	cin >> n >> m >> S; S = "#" + S;
	for (int i = 1; i <= m; i++) {
		cin >> l[i] >> r[i];
		if (R >= r[i])continue;
		for (int j = 1; j < i; j++) {
			if (l[j] == l[i])used[j] = false;
		}
		R = r[i]; used[i] = true;
	}
	for (int i = 0; i <= n; i++) { s[i] = -1; t[i] = 1e9; }
	int V = 1, W = 0;
	for (int i = 1; i <= m; i++) {
		if (used[i] == false)continue;
		if (W < l[i]) {
			int u = 0; for (int j = 1; j <= W; j++)u += (S[j] - '0');
			s[W] = u; t[W] = u;
			for (int j = W + 1; j < l[i]; j++) {
				if (S[j] == '1')u++; s[j] = u; t[j] = u;
			}
			V = l[i];
		}
		int cnt = 0, u = 0; for (int j = 1; j < V; j++)cnt += (S[j] - '0');
		for (int j = V; j <= W; j++)u += (S[j] - '0');
		s[l[i] - 1] = cnt + max(0, (l[i] - V) - max(0, ((W - V + 1) - u)));
		t[l[i] - 1] = cnt + min(l[i] - V, u);
		W = r[i];
	}
	int u = 0; for (int j = 1; j <= W; j++)u += (S[j] - '0');
	s[W] = u; t[W] = u;
	for (int j = W + 1; j <= n; j++) {
		if (S[j] == '1')u++; s[j] = u; t[j] = u;
	}

	int X = 0; for (int i = 1; i <= n; i++)X += (S[i] - '0');
	dp[0][0] = 1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (!(s[i] <= j && j <= t[i])) { dp[i][j] = 0; continue; }
			dp[i + 1][j] += dp[i][j]; dp[i + 1][j] %= mod;
			dp[i + 1][j + 1] += dp[i][j]; dp[i + 1][j + 1] %= mod;
		}
	}
	cout << dp[n][X] % mod << endl;
	return 0;
}

Measured memory_bytes: 35456
sig = " .,-'?"
dic = {
    0b1101: " ",
    0b1000000: "'",
    0b1000011: ",",
    0b110010001: "-",
    0b1010001: ".",
    0b1000001: "?",
    0b1100101: "A",
    0b110011010: "B",
    0b10101: "C",
    0b10001: "D",
    0b1110: "E",
    0b101001: "F",
    0b110011011: "G",
    0b1010000: "H",
    0b10111: "I",
    0b110011000: "J",
    0b10110: "K",
    0b100100: "L",
    0b110011001: "M",
    0b110011110: "N",
    0b100101: "O",
    0b1111: "P",
    0b110011111: "Q",
    0b11000: "R",
    0b100110: "S",
    0b100111: "T",
    0b110011100: "U",
    0b110011101: "V",
    0b1000010: "W",
    0b110010010: "X",
    0b110010011: "Y",
    0b110010000: "Z",
}
while True:
    try:
        t = ""
        for c in raw_input():
            code = ord(c)
            if 65 <= code <= 90:
                t += format(code - 65, '05b')
            else:
                t += format(sig.index(c) + 26, '05b')
        q = 1
        ans = ""
        for e in t:
            q = (q<<1) + int(e)
            if dic.has_key(q):
                ans += dic[q]
                q = 1
        print ans
    except EOFError:
        break

Measured memory_bytes: 4280
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};

int main(){
  ll N;
  cin>>N;
  ll C[N-1],S[N-1],F[N-1];
  for(ll i=0;i<N-1;i++) cin>>C[i]>>S[i]>>F[i];
  for(ll i=0;i<N-1;i++){
    ll t=S[i]+C[i];
    for(ll j=i+1;j<N-1;j++){
      while(S[j]>t||t%F[j]!=0) t++;
      t+=C[j];
    }
    cout<<t<<endl;
  }
  cout<<"0"<<endl;
}


Measured memory_bytes: 256
a,b=map(int,input().split())
s = input()
x = ['0','1','2','3','4','5','6','7','8','9']
if s[a] !='-':
    print('No')
    exit()
s =list(s)
del s[a]
for i in s:
    if i not in x:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 9188
#ABC063B
S = input()
all_dif = True
for i in range(len(S)):
    if i == len(S)-1:
        break
    for j in range(1,len(S)-i):
        if S[i] == S[i+j]:
            all_dif = False
if all_dif:
    print("yes")
else:
    print("no")

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>
#include <chrono>
#include <set>


#define rep(i,p,q) for(ll i = p;i < q;i++)
#define ll long long

using namespace std;

vector<vector<ll>> graph;
vector<ll> query;
vector<ll> ans;
vector<ll> visited;


const long long MAX_N = 1 << 17;

long long dat[2 * MAX_N - 1];

ll ecd(ll a, ll b) {
	if (a < b) swap(a, b);
	if (b == 0) return a;
	else {
		return ecd(b, a % b);
	}
}

ll pow(ll a, ll b) {
	vector<ll> d = vector<ll>((ll)(log(b)) + 2);
	d[0] = a;
	rep(i, 1, d.size()) d[i] = d[i - 1] * d[i - 1];
	ll ret = 1;
	rep(i, 0, log(b) + 1) {
		if (b & 1 << i) ret *= d[i];
	}
	return ret;
}

const long MAX = 1000001;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//145 E
int main(void) {
	ll n, t;
	cin >> n >> t;
	vector<ll> a = vector<ll>(n);
	vector<ll> b = vector<ll>(n);
	rep(i, 0, n) cin >> a[i] >> b[i];
	vector<tuple<ll, ll>> min = vector<tuple<ll, ll>>(n);
	rep(i, 0, n) min[i] = make_tuple(a[i], b[i]);
	sort(min.begin(), min.end());
	//j分でいけるマックス
	vector<vector<ll>> dp = vector<vector<ll>>(n, vector<ll>(t,0));
	rep(i, get<0>(min[0]), t) {
		 dp[0][i] = get<1>(min[0]);
	}
	rep(i, 1, n) {
		for (ll j = 1; j < t; j++) {
			if (j - get<0>(min[i]) >= 0) {
				dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - get<0>(min[i])] + get<1>(min[i]));
			}
			else
				dp[i][j] = dp[i - 1][j];
		}
	}
	ll ans = dp[0][t - 1];
	rep(i, 1, n) {
		ans = max(ans, dp[i - 1][t - 1] + get<1>(min[i]));
	}
	cout << ans << endl;
}


Measured memory_bytes: 70784
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 2000;
const int M = 100000007;

int C[N+1][N+1];

void init(){
  for(int i=0;i<N;i++){
    C[i][0] = C[i][i] = 1;
    for(int j=0;j<i;j++) C[i][j] = (C[i-1][j-1] + C[i-1][j]) % M;
  }
}

main(){
  int r, c, sy, sx, ty, tx, by, bx;
  init();
  int dy[] = {-1, -1, -1, 0, 0, 0, 1, 1, 1};
  int dx[] = {-1, 0, 1, -1, 0, 1, -1, 0, 1};
  cin >> r >> c >> sy >> sx >> ty >> tx;
  int ans = 0;
  by = abs(ty - sy);
  bx = abs(tx - sx);
  for(int i=0;i<9;i++){
    int ny = abs(ty + r * dy[i] - sy);
    int nx = abs(tx + c * dx[i] - sx);
    if(by + bx > ny + nx){
      by = ny; bx = nx;
      ans = C[by+bx][by];
    }else if(by + bx == ny + nx){
      ans = (ans + C[ny+nx][ny]) % M;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 15924
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int x, y,n,date[22][22],m,xx,yy,ans[11],an;
	an = 0;
	while (1) {
		cin >> x >> y;
		if (x== 0 && y == 0) {
			goto a;
		}
		cin >> n;
		an = an + 1;
		for (int i = 0; i <= y; i++) {
			for (int z = 0; z <= x; z++) {
				date[z][i] = 0;
			}
		}
		for (int i = 1; i <= n; i++) {
			cin >> m >> xx;
			date[m][xx] = -999999999;
		}
		for (int i = 1; i <= y; i++) {
			for (int z = 1; z <= x; z++) {
				if (i == 1 && z == 1) {
					date[i][z] = date[i][z] + 1;
					if (date[i][z] <= 0) {
						date[i][z] = 0;
					}
					goto d;
				}
				date[z][i] = date[z - 1][i] + date[z][i - 1] + date[z][i];
				if (date[z][i] <= 0) {
					date[z][i] = 0;
				}
			d:;
			}
		}
		cout << date[x][y] << endl;;
	}
a:;
}


Measured memory_bytes: 3016
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<n;++i)

typedef long long ll;
using namespace std;
int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    string s;
    ll n, q;
    cin >> n >> q;
    cin >> s;
    vector<int> l = {};
    vector<int> r = {};

    int cnt = 0;
    vector<int> a(n, 0);
    REP(i, n-1){
        if(s[i] == 'A' && s[i+1]=='C'){
            ++cnt;
        }
        a[i+1] = cnt;
    }

    vector<int> ans(q, 0);
    REP(i, q){
        int x, y;
        cin >> x >> y;
        --x; --y;
        ans[i] = a[y]-a[x];
    }

    REP(i, q){
        cout << ans[i] << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 1872
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

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

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; }

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    LL N,K; cin >> N >> K;
    if(N < K){
        cout << min(N,K-N) << endl;
    }else if(N == K){
        cout << 0 << endl;
    }else{
        N = N % K;
        cout << min(N,K-N) << endl;
    }

}


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

int main(){
  int H,W,K;cin>>H>>W>>K;
  vector<string> c(H);
  rep(i,H)cin>>c[i];
  int ans=0;

  for(int i=0; i<(1<<H); i++){
    for(int j=0; j<(1<<W); j++){
      
      int cnt = 0;
      for(int h=0; h<H; h++){
        for(int w=0; w<W; w++){
          if(i&(1<<h) || j&(1<<w))continue;
          if(c[h][w]=='#')cnt++;
        }
      }

      if(cnt==K)ans++;
    }
  }

  cout<<ans<<endl;
}

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

int main(){
    ll n,k,sum=0;
  	cin >>n >>k;
    for(int i=k;i<=n+1;i++){
        sum+=(i%mod)*(n-i+1)+1;
        sum=sum%mod;
    }
    cout << sum;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    ll n,k; cin >> n >> k;
    vl p(n);
    rep(i,n)cin>>p[i];
    sort(all(p));
    ll res = 0;
    rep(i,k){
        res += p[i];
    }
    out(res);
}

Measured memory_bytes: 3664
#include<stdio.h>
#include<cmath>
int main(){
	int A,B,C,D;
	scanf("%d%d%d%d",&A,&B,&C,&D);
	int are1,are2;
	are1=A*B;
	are2=C*D;
	if(are1>=are2){
		printf("%d\n",are1);}
		else{
			printf("%d\n",are2);}
			return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  const ll mod = 1e9 + 7;
  int n;
  cin >> n;
  string s1, s2;
  cin >> s1 >> s2;
  ll ans;
  if (s1[0] == s2[0]) ans = 3;
  else ans = 6;
  for (int i = 0; i < n - 1; i++) {
    if (s1[i] == s2[i]) {
      ans *= 2;
      ans %= mod;
    } else {
      if (s1[i + 1] == s1[i] || s2[i + 1] == s2[i]) continue;
      else if (s1[i + 1] == s2[i + 1]) continue;
      else {
        ans *= 3;
        ans %= mod;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N = int(readline())
    s = input()

    red = s.count("R")
    blue = s.count("B")

    if red > blue:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 61640
N = int(input())
tmp = [0] * 101
tmp[1] = tmp[2] = tmp[3] = 0
tmp[4] = tmp[7] = 1
for k in range(4, 101):
  if tmp[k] == 0:
    continue
  if k + 4 <= 100:
    tmp[k + 4] += 1
  if k + 7 <= 100:
    tmp[k + 7] += 1
ans = 'Yes' if tmp[N] >= 1 else 'No'
print(ans)

Measured memory_bytes: 3064
"use strict";
    
const main = arg => {
    arg = arg.split("\n");
    const S = arg[0].split("");
    
    let flag    = false;
    let answer  = [];
    let counter = 0;
    
    const start = S.indexOf("A");
    const end   = S.reverse().indexOf("Z");
    
    console.log((S.length - end) - start);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 9756
import java.lang.reflect.Array;
import java.util.*;


public class Main {

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

        if (S.charAt(2) == S.charAt(3) && S.charAt(4) == S.charAt(5)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
int main()
{   int a, b;
    cin >> a >> b;
    if (a+b>=a-b&&a+b>=a*b)
       cout << a+b << endl;
    else if (a-b>=a+b&&a-b>=a*b)
            cout << a-b << endl;
    else
       cout << a*b << endl;
    return 0;
}

Measured memory_bytes: 256
using System;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] line = Console.ReadLine().Split(' ');
            double a = double.Parse(line[0]);
            double b = double.Parse(line[1]);
            double h = double.Parse(line[2]);
            double m = double.Parse(line[3]);

            double ax = a*Math.Cos(((h/12) + (m/60/12))*2*Math.PI);
            double ay = a*Math.Sin(((h/12) + (m/60/12))*2*Math.PI);
            double bx = b*Math.Cos(m/60*2*Math.PI);
            double by = b*Math.Sin(m/60*2*Math.PI);

            double ex = (ax - bx) * (ax - bx);
            double ey = (ay - by) * (ay - by);
            double d = Math.Sqrt(ex + ey);
            Console.WriteLine(d);
        }
    }
}


Measured memory_bytes: 28012
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
long long a[30000010];
int main() {
    int N;
    cin >> N;
    long long max = 0;
    int n = 3*N;

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

    sort(a, a + n, greater<int>());

    for(int i = 1; i <= N; i++){
        int k = 2*i - 1;
        max += a[k];
    }
    
    cout << max << endl;

    return 0;
}

Measured memory_bytes: 5952
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	int d[101] = { 0 }, a, m = 0;
	while (cin >> a){
		d[a]++;
		m = max(m, d[a]);
	}
	for (int i = 1; i <= 100; i++){
		if (m == d[i])cout << i << endl;
	}
	return 0;
}

Measured memory_bytes: 3028
#include<iostream>
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
ll n,m;
int main()
{
    while(~scanf("%lld%lld",&n,&m))
    {
        if(m<n*2)
            printf("%lld\n",m/2);
        else
        {
            printf("%lld\n",(m-n*2)/4+n);
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++)cin>>A.at(i);
  sort(A.begin(),A.end());
  cout<<A.at(N-1)-A.at(0)<<endl;
}

Measured memory_bytes: 256
#include <stdint.h>
#include <array>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <limits>
#include <tuple>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstdio>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl


void solve(long long N, long long K, std::vector<long long> h){
  vector<ll> min_sum(N, LLONG_MAX);

  min_sum[0] = 0;
  for (int i = 1; i < N; ++i) {
    for (int j = 1; j <= K; ++j) {
      if (i - j >= 0) {
        min_sum[i] = min(min_sum[i],
                         min_sum[i - j] + abs(h[i] - h[i - j]));
      }
    }
  }
  std::cout << min_sum[N - 1] << std::endl;
}

int main(){
  long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> h(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&h[i]);
    }
  solve(N, K, std::move(h));
  return 0;
}


Measured memory_bytes: 1792
n = int(input())
a_l = list(map(int,input().split()))
b_l = list(map(int,input().split()))
c_l = list(map(int,input().split()))
sum = 0
past = a_l[0]
for i in a_l:
        sum += b_l[i-1]
        if i == past + 1:
                sum += c_l[past-1]
        past = i
print(sum)

Measured memory_bytes: 3064
// template for atcoder beginner
// when you create a *.cp file, this template is loaded

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

int main() {
  int N;
  cin >> N;
  if (N == 0)
    cout << 2;
  else if (N == 1)
    cout << 1;
  else {
    vector<int64_t> Lucas = {2, 1};
    for (int i = 0; i < N - 1; i++) {
      Lucas.push_back(Lucas.at(0) + Lucas.at(1));
      swap(Lucas.at(0), Lucas.at(2));
      Lucas.pop_back();
      swap(Lucas.at(0), Lucas.at(1));
    }
    cout << Lucas.at(1);
  }
}



Measured memory_bytes: 256
#include<iostream> 
#include<algorithm>
#include<cstdio>
using namespace std;
int s[100];
int main()
{
	int n,m;
	cin>>n>>m;
	int a,b;
	for(int i=1;i<=m;i++)
	{
		cin>>a>>b;
		s[a]++;
		s[b]++;
	}
	for(int i=1;i<=n;i++)
	{
		cout<<s[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
z=[tuple(map(int,input().split()))for _ in range(n)]
x=[i for i,_ in z]
y=[j for _,j in z]
x.sort()
y.sort()
a=10**20
for i,l in enumerate(x):
    for r in x[i+1:]:
        for v,d in enumerate(y):
            for u in y[v+1:]:
                if sum([1for i,j in z if l<=i<=r and d<=j<=u])>=k:
                    a=min(a,(r-l)*(u-d))
print(a)

Measured memory_bytes: 62556
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
    int n;
    cin >> n;
    if (n/100*111 >= n){
        cout << n/100*111 << endl;
    } else {
        cout << (n/100+1)*111 << endl;
    }
    return 0;
}


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

int main(){
	int n, i;
	int result = 100000;
	
	cin >> n;

	for (i = 0; i < n; i++) {
		result += result*0.05;
		if(result - (result/1000*1000) > 0){
			result = result/1000*1000+1000;
		}
	}
	
	cout << result << endl;

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<deque>
#include<algorithm>
#include<math.h>
#include<string>
using namespace std;
int main() {
	int ans = 0;
	string s;
	cin >> s;
	if (s[0] != 65) {
		cout << "WA" << endl;
		return 0;
	}
	for (int i = 2; i < s.size() - 1; i++) {
		if (s[i] == 'C') {
			ans = i;
			break;
		}
	}
	if (ans == 0) {
		cout << "WA" << endl;
			return 0; 
	}
	for (int i = 1; i < s.size(); i++) {
		if (i == ans)
			continue;
		else {
			if (s[i] < 97) {
				cout << "WA" << endl;
				return 0;
			}
		}
	}
	cout << "AC" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lint long long int
using namespace std;
int main() 
{
	string s;
	cin>>s;
	if(s=="ABC")
	{
		cout<<"ARC"<<endl;
	}
	else
	{
		cout<<"ABC"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<math.h>
using namespace std;
int main(void){
    int N,j,k,count,max,ans;
    count=0;
    max=0;
    cin>>N;
    for(j=0;j<N;j++){
        k=j;
       while((k+1)%2==0){
           k=k/2;         
           count=count+1;
       }
       if(count>=max){
           max=count;
       }
       count=0;
    }
    ans=pow(2,max);
    cout<<ans<<endl; 
    

    return 0;
}

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

int main(){
	string s,t;
	cin>>s>>t;
	sort(s.begin(),s.end());
	sort(t.begin(),t.end(),greater<int>());
	if(s<t)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

int main()
{
	int n,m,i,j,k,x;
	map<string,int> cost;
	typedef vector<string> VS;
	typedef pair<string,VS>Recipe;
	vector<Recipe> recipe;	
	string s;
	while(cin>>n,n)
	{
		cost.clear();
		recipe.clear();

		for(i=0;i<n;++i) cin>>s>>x, cost[s]=x;
		cin>>m;
		for(i=0;i<m;++i)
		{
			cin>>s>>x;
			recipe.push_back( Recipe(s,VS()) );
			for(j=0;j<x;++j)
			{
				cin>>s;
				recipe.back().second.push_back(s);
			}
		}

		for(i=0;i<m;++i)
			for(j=0;j<m;++j)
		{
			x=0;
			for(k=0;k<recipe[j].second.size();++k)
				x += cost[ recipe[j].second[k] ];
			cost[recipe[j].first] = min(cost[recipe[j].first], x);
		}

		cin>>s;
		cout<<cost[s]<<endl;

	}
	return 0;
}

Measured memory_bytes: 0
n = int(input())
s = input()

w = [0]*n
e = [0]*n
if s[0] == "W": w[0] = 1
else: e[0] = 1
for i in range(1,n):
  if s[i] == "W":
    w[i] = w[i-1]+1
    e[i] = e[i-1]
  else:
    w[i] = w[i-1]
    e[i] = e[i-1]+1

ans = float("inf")
for i in range(n):
  t = 0
  if i != 0: t += w[i-1]
  if i != n-1: t += e[-1] - e[i]
  if t < ans: ans = t
print(ans)  

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
typedef long long ll;

void test_case(){
    
}

int main() {
    fastio
    int n; cin >> n;
    int a[n];
    rng(i, 0, n)
		cin >> a[i];
		
	int res = INT_MAX;
	int curr = 0;
	for(int i = 0; i<= 100; i++){
		curr = 0;
		for(int j = 0; j<n ; j++)
			curr += abs(a[j] - i)*abs(a[j]-i);
			
		res = min(res, curr);
	}
    cout<<res<<endl;
	return 0;
}






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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned short int us;

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(15);

    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for (int i = 0; i < n; ++i)
        cin >> h[i];

    vector<int> a(n, INT_MAX);
    a[0] = 0;

    for (int i = 1; i < n; ++i)
    {
        for (int j = max(0, i - k); j < i; ++j)
            a[i] = min(a[i], a[j] + abs(h[j] - h[i]));
    }

    cout << a[n - 1];
}























Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	string s,s1="...";
	cin>>t;
	cin>>s;
	if(s.length()>t){
		s=s.substr(0,t)+s1;
	}
	cout<<s;
	return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#include <fstream>
#include <cstdio>
using namespace std;
// vector<pair<int,int> > v;
// cin.ignore();//twice getline(cin,s);
// g++ iterator.cpp -std=c++17
// cout<<(A + B == C ? "YES" : "NO")<<endl;
// __gcd(a,b)
// string s=to_string(n);
// string p=s.substr(0,len);
// sort(arr, arr+n, greater<int>());
// cout<<fixed<<setprecision(9)<<pi<<endl
// const  double pi = acos(-1.0);
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define vll vector<ll>
#define mll map<ll,ll >
#define mlli map<ll,ll>::iterator
#define size size()
#define endl "\n"
#define ll long long int
#define ld long double
void fast(){ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);}


int main(void)
{
	fast();
	int h1,m1,h2,m2,k;
	cin>>h1>>m1>>h2>>m2>>k;
	cout<<(h2-h1)*60+(m2-m1)-k<<endl;
}

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


int main() {

  int64_t n;
  cin>>n;


  int cnt=0;
  for(int64_t i=1;i<=n;i++){
  cnt=0;
  for(int64_t x=1;x*x<=i;x++){
    for(int64_t y=1;y*y<=i;y++){
      long double xd=x,yd=y,id=i;
      if(4.0*id-3*xd*xd-2.0*xd*yd-3*yd*yd>0){
      int64_t z=(int64_t)(0.5*(sqrt(4.0*id-3*xd*xd-2.0*xd*yd-3*yd*yd)-xd-yd));
      //int64_t z=(sqrt(4*i-3*x*x-2*x*y-3*y*y)-x-y)/2;
      if(z>=1&&x*x+y*y+z*z+x*y+y*z+z*x==i)
          cnt++;
      }
    }
  }
  cout<<cnt<<endl;
  }

	return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second

using namespace std;

using ld = long double;
using ll = long long int;

const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll in(){long long int x; assert(scanf("%lld", &x) == 1); return x;}
ld fin(){double x; assert(scanf("%lf", &x) == 1); return x;}
char yuyushiki[1000010]; string stin(){assert(scanf("%s", yuyushiki) == 1); return yuyushiki;}

// head

struct Mod{
  unsigned n;
  Mod() : n(0){}
  Mod( ll x ){
    if( x < 0 ) n = x%MOD+MOD;
    else n = x%MOD;
  }
};
Mod operator + ( Mod a  , Mod b ){ return Mod( a.n + b.n ); }
Mod operator +=( Mod &a , Mod b ){ return a = a + b; }
Mod operator - ( Mod a ){ return Mod( MOD - a.n ); }
Mod operator - ( Mod a  , Mod b ){ return Mod( a.n + MOD - b.n ); }
Mod operator -=( Mod &a , Mod b ){ return a = a - b; }
Mod operator * ( Mod a  , Mod b ){ return Mod( (ll)a.n * b.n ); }
Mod operator *=( Mod &a , Mod b ){ return a = a * b; }
Mod modpow( Mod x , ll k ){
  Mod res = 1;
  while( k ){
    if( k & 1 ) res *= x;
    k /= 2;
    x *= x;
  }
  return res;
}
ll extgcd( ll a , ll b , ll &x , ll &y ){
  ll d = a;
  if( b != 0 ){
    d = extgcd( b , a % b , y , x );
    y -= a / b * x;
  } else {
    x = 1, y = 0;
  }
  return d;
}
Mod inv( Mod a ){ ll x, y; assert( extgcd( a.n , MOD , x , y ) == 1 ); return Mod( x ); }
Mod operator / ( Mod a  , Mod b ){ return Mod( (ll)a.n * inv(b).n ); }
Mod operator /=( Mod &a , Mod b ){ return a = a / b; }

int main(){

  ll n = in();
  vector<ll> a(n);
  REP(i, n){
    a[i] = in();
  }
  vector<ll> s(n+1);
  REP(i, n){
    s[i+1] = s[i] + a[i];
  }
  vector<vector<ll>> dp(n + 1, vector<ll>(n + 1, INFLL));

  REP(i, n){
    dp[i][i+1] = 0;
  }
  FOR(l, 2, n + 1){
    REP(i, n){
      ll j = i + l;
      if(j > n){
        break;
      }
      ll add = s[j] - s[i];
      FOR(l, i + 1, j){
        chmin(dp[i][j], dp[i][l] + dp[l][j] + add);
      }
    }
  }
  cout << dp[0][n] << endl;
  
  return 0;
}


Measured memory_bytes: 1536
from collections import defaultdict
from itertools import accumulate

n,k = map(int, input().split())

a = list(map(int,input().split()))
s = list(accumulate([0]+a))
b = [(s[i]-i)%k for i in range(n+1)]

d = defaultdict(int)
# 初期化
for i in range(min(k-1,n+1)):
    d[b[i]]+=1

ans = 0
for i in range(n):
    # 自分を除外し、k-1個先が存在すれば加える。
    d[b[i]]-=1
    if i+k-1<=n:
        d[b[i+k-1]]+=1
    ans += d[b[i]]

print(ans)




Measured memory_bytes: 118372
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;
typedef long double ld;
int main(){
    ld a,b,x,y;
    cin>>a>>b>>x>>y;
    int is=0;
    if(a/2==x&&b/2==y){
        is = 1;
    }
    cout<<fixed<<setprecision(10)<<a*b/2<<" "<<is;
    
    return 0;
}


Measured memory_bytes: 256
import Data.Int
import Control.Monad
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as VM
import qualified Data.ByteString.Char8 as BS

main = do
  [n,maxW] <- map (read . BS.unpack) . BS.words <$> BS.getLine
  -- 1 <= n <= 100
  -- 1 <= w <= 10^5
  items <- V.replicateM n $ do
    [wi,vi] <- map (read . BS.unpack) . BS.words <$> BS.getLine
    -- wi <= w, vi <= 10^9
    return (wi :: Int, fromIntegral vi :: Int64)
  let result = V.foldl' (\vec (wi,vi) -> V.generate (maxW+1) (\u -> if u - wi >= 0 then max (vec V.! u) (vec V.! (u - wi) + vi) else vec V.! u)) (V.replicate (maxW + 1) 0) items
  print (V.maximum result :: Int64)


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    string S;
    cin >> S;

    ll cnt0 = 0, cnt1 = 0;
    for (const auto& c : S) {
        if (c == '0')
            ++cnt0;
        else
            ++cnt1;
    }
    cout << min(cnt0, cnt1) * 2 << "\n";
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 512
//
//  main.cpp
//  Study
//
//  Created by 佐々木勇星 on 2020/03/12.
//  Copyright © 2020 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <iomanip>

using namespace std;

int main(int argc, const char * argv[]) {
    
    int l;
    cin >> l;
    
    double a, b, c;
    double ans;
    
    a = l/3.0;
    b = l/3.0;
    c = l/3.0;
    
    //cout << a << " " << b << " " << c << endl;

    ans = a * b * c;
    
    //cout << fixed << setprecision(12) << (double)l*l*l / 27 << endl;
    cout << fixed << setprecision(12) << ans << endl;

    //cout << ans << endl;
    
    //printf("%.12f", (double)l*l*l / 27);
    
    //cout << (double)l * l * l / 27 << endl;


    return 0;
}


Measured memory_bytes: 256
anslist = []

while True:
    m, nmin, mmax = map(int, input().split())
    if m == 0 and nmin == 0 and mmax == 0:
        break
    p = [int(input()) for i in range(m)]
    p.sort()

    ans = 0
    line = 0
    for i in range(m - mmax, m - nmin + 1):
        if ans < p[i] - p[i - 1]:
            ans = p[i] - p[i - 1]
            line = i
    #print(line)
    anslist.append(m - line)

for i in anslist:
    print(i)


Measured memory_bytes: 5628
import math

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

L = [A[0]]
R = [A[-1]]

ans = 0

for i in range(1, N):
  L.append( math.gcd(L[i-1], A[i]) )
  R.append( math.gcd(R[i-1], A[-(1+i)]))

R.reverse()

for i in range(N):
  if i == 0:
    ans = max(ans, R[i+1])
  elif i == N-1:
    ans = max(ans, L[i-1])
  else:
    ans = max(ans, math.gcd(L[i-1], R[i+1]))

print(ans)

Measured memory_bytes: 21664
def someone_ans():
    def binary_search(L, key, mode):
        low, high = 0, len(L)
        mid = len(L) // 2
        while low <= high - 1:
            if L[mid] < key and mode == 0 or L[mid] <= key and mode == 1:
                low = mid + 1
            else:
                high = mid
            mid = (low + high) // 2
        return high

    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    A.sort()
    C.sort()
    ans = 0
    for i in B:
        Ai = binary_search(A, i, 0)
        Ci = len(C) - binary_search(C, i, 1)
        ans += Ai*Ci
    return ans


# print(m())
print(someone_ans())

Measured memory_bytes: 23328
//NAME-ADITYYA OJHA
                                               /*
                                                      GURU(MENTOR)-AARADHYA
                                               */
/*
 *     Heart beats fast
 *         Colors and promises
 *             How to be brave
 *                 How can I love when I am afraid to fall...
                                             (courtesy-amnesiac_dusk)
 */

#include <bits/stdc++.h>
#define ll long long int
#define forin for(int i=0;i<n;i++)
#define pb push_back
#define vx vector<ll> x
#define vy  vector<ll> y
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define  f   first
#define  s   second
#define mod 1000000007
using namespace std;

/*
check for corner cases(for n==1)
 check for int overflow
 run on some sample cases before submitting
*/

/*FERMAT THEOREM

       pow(x,m-1)%m=1 (x and m are co-prime)
*/
/*MODULAR INVERSE

        pow(x,-1)=pow(x,m-2) (x and m are co-prime)
*/

/*
ll  mode(ll x,ll n,ll mod)
{
    if(n==0)return 1%mod;

    ll u=mode(x,n/2,mod);
    u=(u*u)%mod;
    if(n & 1)u=(u*x)%mod;
}
*/




const ll INF=1e11+ 5;
int main()
{
   fast;
   ll n;
   cin>>n;
  ll a[n];
  forin cin>>a[i];
  sort(a,a+n);
  if(n==1)
  {
      cout<<0<<endl;
      return 0;
  }
   ll ans=a[n-1];
   ll cnt=0;
   ll j=n-2;
   for(int i=n-3;i>=0;i--)
   {    //cout<<i<<" "<<a[j]<<endl;
        cnt++;
            ans+=a[j];
       //cout<<ans<<endl;

       if(cnt==2)
       {
           j--;
           cnt=0;
       }
   }
   cout<<ans<<endl;
}


















































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

using ll=long long;
const ll MOD=1e9+7;
ll powm(ll x,ll k){
    ll res=1;
    while(k){
        if(k&1) res=(res*x)%MOD;
        k>>=1;
        x=(x*x)%MOD;
    }
    return res;
}

ll inv(ll x){
    return powm(x,MOD-2);
}
int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    
    for(int i=0;i<n;i++) cin>>a[i];
    if(n==1){
        cout<<a[0]<<endl;
        return 0;
    }
    ll nf=1;
    for(int i=0;i<n;i++){
        nf*=(i+1);
        nf%=MOD;
    }
    ll mot=(nf*2)%MOD;
    vector<ll> szk(n);
    for(int i=1;i<n;i++){
        szk[i]=(mot*inv(i+1))%MOD*inv(i+2)%MOD;
    }
    vector<ll> sum(n+1,0);
    for(int i=0;i<n;i++){
        sum[i+1]=(sum[i]+szk[i])%MOD;
    }
    
    stack<ll> piyo;
    ll tmp=sum[n-1];
    ll res=0;
    for(int i=1;i<(n+1)/2;i++){
        //cerr<<i<<endl;
        //cerr<<tmp<<endl;
        res+=(tmp*a[i])%MOD;
        res%=MOD;
        piyo.push(tmp);
        tmp+=(sum[n-1-i]-sum[i+1])%MOD;
        tmp%=MOD;
    }
    if(n&1) piyo.pop();
    for(int i=(n+1)/2;i+1<n;i++){
        //cerr<<"#"<<i<<endl;
        ll v=piyo.top(); piyo.pop();
        res+=(v*a[i])%MOD;
        res%=MOD;
    }
    tmp=0;

    for(int x=n-1;x>=1;x--){
        tmp+=(nf*inv(x+1))%MOD;
        tmp%=MOD;
        res+=(tmp*a[x-1])%MOD;
        res%=MOD;
        res+=(tmp*a[n-x])%MOD;
        res%=MOD;
    }
    
    for(int i=0;i<n;i++){
        res+=(nf*a[i])%MOD;
        res%=MOD;
    }

    cout<<(res%MOD+MOD)%MOD<<endl;

    return 0;
}

Measured memory_bytes: 3020
#include <stdio.h>

int main()
{
  int N, v, i ,j ,k;
  int A[100] = {0};
  
  scanf("%d", &N);
  
  for (i = 0; i < N; i++){
    scanf("%d", &A[i]);
  }
  
  for (k = 0; k < N - 1; k++){
    printf("%d ", A[k]);
  }
  printf("%d\n", A[k]);
  
  for (i = 1; i < N; i++){
    v = A[i];
    j = i - 1;
    while (j >= 0 && A[j] > v) {
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    for (k = 0; k < N - 1; k++){
      printf("%d ", A[k]);
    }
    printf("%d\n", A[k]);
  }
  
  return 0;
}

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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    ll N;
    ll a = 1, b  = 1;
    cin >> N;
    for(ll i = 0;i < N;i++) {
        ll temp;
        cin >> temp;
        a *= 3;
        if(temp % 2 == 0) b *= 2;
    }
    cout << a - b << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

int main(){
    int n[100],x[100];
    int i,j,k;
    int a=0,b=0;
    int com[100];
    int x0,x1,x2,x3;
    
    for(a=0;;a++){
        std::cin>>n[a]>>x[a];
        if(n[a]==0&&x[a]==0){
            break;
        }
        b+=1;
    }

    for(a=0;a<b;a++){
        com[a] = 0;
    }    

    int sum;

    for(a=0;a<b;a++){
//        x0=n[a];
        for(i=n[a];i>=3;i--){
//            x1=i;
            for(j=i-1;j>=2;j--){
//                x2=j;
                for(k=j-1;k>=1;k--){
//                    x3=k;
                    sum=i+j+k;
                    if(sum==x[a]){
                        com[a]+=1;
                    }
                }
            }
        }
    }

    for(a=0;a<b;a++){
        std::cout<<com[a]<<std::endl;
    }

return 0;    
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define ll long long
#define pp push_back
#define fr first
#define sc second

using namespace std;

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

    double r; cin >> r;
    cout <<fixed << setprecision(2) <<  2.0 * acos(-1) * r << '\n';

    return 0;
}


Measured memory_bytes: 3804
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.StringTokenizer;

public class Main {

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

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		
		int [][] path = new int[4][4];
		
		for(int i = 0; i < 3; i++) {
			int a = fs.nextInt()-1;
			int b = fs.nextInt()-1;
			
			path[a][b] = 1;
			path[b][a] = 1;
		}
		
		for(int i = 0; i < 4; i++) {
			if(canStartHere(path, i)) {
				System.out.println("YES");
				return;
			}
		}
		
		System.out.println("NO");
	}
	
	boolean canStartHere(int[][] path, int start) {
		int[] visited = new int[4];
		visited[start] = 1;
		
		ArrayDeque<Integer> town = new ArrayDeque<>();
		for(int i = 0; i < 4; i++) {
			if(path[start][i] == 1) {
				town.add(i);
			}
		}
		
		if(town.size() >= 2) {
			return false;
		}
		
		while(!town.isEmpty()) {
			int nextTown = town.poll();
			visited[nextTown] = 1;
			
			for(int i = 0; i < 4; i++) {
				if(path[i][nextTown] == 1 && visited[i] == 0) {
					town.add(i);
				}
			}
			
			if(town.size() >= 2) {
				return false;
			}
		}
		
		for(int i = 0; i < 4; i++) {
			if(visited[i] == 0) {
				return false;
			}
		}
		return true;
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


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

#define INF (1<<25)

int d[1000][1000];
char grid[1000][1000];
pair<int,int>point[10];
int dy[4]={-1,1,0,0};
int dx[4]={0,0,-1,1};
int h,w,n;

int bfs(int sy, int sx, int gy, int gx){
	queue< pair<int,int>>Q;
	Q.push( {sy,sx} );

	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			d[i][j]=INF;
		}
	}
	d[sy][sx]=0;

	while(Q.empty()==false){
		pair<int,int> now=Q.front();	Q.pop();
		int y=now.first, x=now.second;

		for(int i=0;i<4;i++){
			int nY=y+dy[i], nX=x+dx[i];
			if(nY<0||nX<0||nY>=h||nX>=w)continue;
			else if(d[nY][nX]==INF && grid[nY][nX]!='X'){
				d[nY][nX]=d[y][x]+1;
				Q.push( {nY,nX} );
			}

			if(nY==gy && nX==gx){
				return d[nY][nX];
			}
		}
	}

	cout<<"ERROR"<<endl;
	return -1;
}

int main(){
	cin>>h>>w>>n;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>grid[i][j];

			if(grid[i][j]=='S'){
				point[0].first=i;	point[0].second=j;
			}else if('1'<=grid[i][j]&&grid[i][j]<='9'){
				int pos=grid[i][j]-'0';
				point[pos].first=i;		point[pos].second=j;
			}
		}
	}

	int ans=0;
	for(int i=0;i<n;i++){
		int sy=point[i].first, sx=point[i].second;
		int gy=point[i+1].first, gx=point[i+1].second;
		
		ans+=bfs(sy,sx,gy,gx);
	}
	cout<<ans<<endl;

	return 0;
}



Measured memory_bytes: 7888