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

//#pragma gcc optimize("O3,unroll-loop")
//#pragma gcc target("sse,sse2,sse3,ssse3,sse4,avx,avx2,fma,abm,mmx,popcnt,tune=native")
#define int long long
//#define double long double
#define MOD 1000000007

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

    int n;
    cin >> n;

    vector<int> v(n + 1);
    for (int i = 1; i <= n; i++)
        cin >> v[i];

    vector<int> pre(n + 1);
    for (int i = 1; i <= n; i++)
        pre[i] = (pre[i - 1] + v[i]) % MOD;

    int ans = 0;
    for (int i = n; i > 1; i--)
        ans = (ans + v[i] * pre[i - 1]) % MOD;
    cout << ans << '\n';

    return 0;
}

//      *   *  *****  *   *  *   *   ****  ****    ****     **    **
//     *   *  *      **  *  *   *  *      *   *  *        * *   * *
//    *****  *****  * * *  *   *  *      ****   *       *  *     *
//   *   *      *  *  **  *   *  *      *  *   *       *****    *
//  *   *  *****  *   *   ***    ****  *   *    ****     *   *****

//      *****  *****  *   *  *      *****  *   *  *****  *****
//        *   *   *  *   *  *        *    **  *    *    *   *
//       *   *   *  *****  *        *    * * *    *    *****
//   *  *   *   *    *    *        *    *  **    *    *
//  ****   *****    *    *****  *****  *   *    *    *


Measured memory_bytes: 6376
public class Main {

	public static void main(String[] args) {
		try (java.util.Scanner sc = new java.util.Scanner(System.in)) {
			final int N = sc.nextInt();
			final int M = sc.nextInt();
			final int T = sc.nextInt();
			final int[] a = new int[N];
			for (int i = 0; i < N; ++i)
				a[i] = sc.nextInt();
			int rvalue = a[0] - M;
			for (int i = 1; i < N; ++i)
				rvalue += Math.max(0, a[i] - a[i - 1] - 2 * M);
			rvalue += Math.max(0, T - a[N - 1] - M);
			System.out.println(rvalue);
		}
	}
	
}



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

#define ll long long
#define ld long double
#define mod 998244353LL
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define endl '\n'
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mp make_pair
#define pb(x) push_back(x)
#define fo(i, a, n) for (i = (a); i < (n); i++)
#define foe(i, a, n) for (i = (a); i <= (n); i++)
// clang-format off
#define vin(a) for (ll i = 0; i < sz(a); i++) { cin >> a[i]; } 
#define vout(a) for (auto x : a) { cout << x << " "; }
#define sws                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0)
// clang-format on
#define pd(x) cout << x
#define sd(x) cin >> x
#define nl cout << endl
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define foreach(i, a)                                                          \
  for (__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i)
#define sz(a) (int)((a).size())
// int dw[8][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};
void solve() {
  ll m, n;
  ll i, j;
  cin >> n >> m;
  vll up, down;
  ll x, y;

  fo(i, 0, m) {
    cin >> x >> y;
    up.pb(x);
    down.pb(y + 1);
  }

  vll dp(n + 1);
  dp[1] = 1;

  foe(i, 1, n) {
    if (i != 2)
      dp[i] = (dp[i] + dp[i - 1]) % mod;
    fo(j, 0, m) {
      if (i + up[j] <= n) {
        dp[i + up[j]] = (dp[i + up[j]] + dp[i]) % mod;
      }
      if (i + down[j] <= n) {
        dp[i + down[j]] = (dp[i + down[j]] - dp[i] + mod) % mod;
      }
    }
  }

  cout << dp[n] << endl;
}

int main() {
  sws;
  solve();
  return 0;
}

Measured memory_bytes: 4768
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
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(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#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 EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	LL n; cin >> n;
	vector<LL> a(n);

	LL mx = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		mx = max(mx, a[i]);
	}

	LL t = 1;
	LL cnt = 0;
	while (mx > t) {
		cnt++;
		t *= 2;
	}
	
	vector<LL> tb(cnt);

	for (LL i = 0; i < n; i++) {
		for (LL j = 0; j < cnt; j++) {
			if (a[i] & (1LL << j)) {
				tb[j]++;
			}
		}

	}

	LL ans = 0;
	for (LL i = 0; i < n - 1; i++) {
		for (LL j = 0; j < cnt; j++) {
			if (a[i] & (1LL << j)) {
				tb[j]--;
			}
		}

		for (LL j = 0; j < cnt; j++) {
			if (a[i] & (1LL << j)) {
				LL x = n - (i + 1) - tb[j];
				x %= MOD;
				x *= (1LL << j)%MOD;
				ans += x;
				ans %= MOD;
			}
			else {
				LL x = tb[j];
				x %= MOD;
				x *= (1LL << j) % MOD;
				ans += x;
				ans %= MOD;
			}
		}

	}

	cout << ans%MOD << endl;
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#define ll long long
#define pb push_back
//#define mp make_pair
#define fr first
#define sc second
#define MAX ((ll)(1e17+100))
#define MX ((ll)(1e5+100))
#define ARRS ((ll)(1e6+100))
#define ARS ((ll)(1e3+100))
#define HS ((ll)(233))
#define MOD ((ll)(1e9+7))
#define EP ((double)(1e-9))
#define LG 21
#define mul(a,b) a=((a)*(b))%MOD
using namespace std;

ll dp[200][200][3];
ll a[ARRS];

ll pw(ll a,ll b){
	ll p=1;
	while(b){
		if(b&1)p=(p*a)%MOD;
		a=(a*a)%MOD;
		b>>=1;
	}
	return p;
}

void go(ll l,ll r,ll d){
	if(l==r){
		dp[l][r][0]=1;
		dp[l][r][1]=1;
		dp[l][r][2]=0;
		return;
	}
	vector<ll> v;
	ll mn=MAX;
	for(int i=l; i<r; i++)
		mn=min(mn,a[i]);
	v.pb(l-1);
	for(int i=l; i<r; i++)
		if(a[i]==mn)v.pb(i);
	v.pb(r);
	for(int i=0; i<v.size()-1; i++)
		go(v[i]+1,v[i+1],mn);
	dp[l][r][0]=1;
	ll t=0;
	for(int i=0; i<v.size()-1; i++){
		mul(dp[l][r][0],dp[v[i]+1][v[i+1]][t]);
		t^=(v[i+1]-(v[i]+1));
		t^=1;
		t&=1;
	}
	dp[l][r][1]=1;
	t=1;
	for(int i=0; i<v.size()-1; i++){
		mul(dp[l][r][1],dp[v[i]+1][v[i+1]][t]);
		t^=(v[i+1]-(v[i]+1));
		t^=1;
		t&=1;
	}
	dp[l][r][2]=1;
	for(int i=0; i<v.size()-1; i++){
		if(v[i]+1!=v[i+1]){
			mul(dp[l][r][2],
				dp[v[i]+1][v[i+1]][0]+
				dp[v[i]+1][v[i+1]][1]+
				dp[v[i]+1][v[i+1]][2]);
			//cout<<v[i]+1<<" - "<<v[i+1]<<endl;
			
			//cout<<
				//dp[v[i]+1][v[i+1]][0]+
				//dp[v[i]+1][v[i+1]][1]+
				//dp[v[i]+1][v[i+1]][2]<<endl;
		}
		if(r!=v[i+1])
		mul(dp[l][r][2],2);
	}
	//cout<<dp[l][r][2]<<endl;
	dp[l][r][2]-=dp[l][r][0]+dp[l][r][1];
	dp[l][r][2]%=MOD;
	dp[l][r][2]+=MOD;
	dp[l][r][2]%=MOD;
	mul(dp[l][r][0],pw(2,mn-d));
	mul(dp[l][r][1],pw(2,mn-d));
	//cout<<l<<" "<<r-1<<" "<<dp[l][r][0]<<" = "<<dp[l][r][1]<<" "<<dp[l][r][2]<<endl;
}

int main(){
	ll n;
	cin>>n;
	for(int i=0; i<n; i++)
		cin>>a[i];
	go(0,n,1);
	cout<<(dp[0][n][0]+dp[0][n][1]+dp[0][n][2])%MOD;
}


Measured memory_bytes: 2432
import java.util.*;


public class Main {
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.nextLine();
		if (a.charAt(2) == a.charAt(3) && a.charAt(4) == a.charAt(5)) {
		    System.out.println("Yes");
		} else {
		    System.out.println("No");
		}
		
    }
}

Measured memory_bytes: 35732
#include <iostream>
#include <cstdio>
#include<algorithm>
using namespace std;
const int maxn = 500000 + 8;
#define inf 0x3f3f3f3f
int n,s[maxn];
int num = 0;

void Merge(int s[],int left,int mid,int right,int p[])
{
    int i = left, j = mid + 1;
    int k = 0;
    while(i <= mid && j <= right)
    {
        if(s[i] <= s[j]){
            p[k++] = s[i++];
            num++;
        }else{
            p[k++] = s[j++];
            num++;
        }
    }
    while(i <= mid) num++,p[k++] = s[i++];
    while(j <= right) num++,p[k++] = s[j++];

    for(int i = 0; i < k; ++i){
        s[left + i] = p[i];
    }
}

void MergeSort(int s[],int left,int right,int p[])
{
    if(left < right)
    {
        //num++;
        int mid = (left + right) / 2;
        MergeSort(s,left,mid,p);
        MergeSort(s,mid+1,right,p);
        Merge(s,left,mid,right,p);
    }
}
void Print(int s[])
{
    for(int i = 0; i < n; ++i){
        printf("%s%d", i == 0 ? "" : " ", s[i]);
    }
    printf("\n%d\n",num);
}
int main()
{
    scanf("%d",&n);
    fill(s,s+n,0);
    int *p;
    p = new int[n+5];
    fill(s,s+n,inf);
    for(int i = 0; i < n; ++i) scanf("%d",&s[i]);
    MergeSort(s,0,n-1,p);
    Print(s);

}

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

int euclid(int a, int b)
{
    if (a < b)
        euclid(b, a);
    if (b == 0)
        return a;
    int r;
    while ((r = a % b))
    {
        a = b;
        b = r;
    }
    return b;
}

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int n;
    cin >> n;
    ll tmp = 1;
    for (int i = 1; i <= n; i++)
        tmp = (tmp * i) % MOD;
    cout << tmp << endl;
}


Measured memory_bytes: 256
import sys

n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
nlist=[]
analist=[0]*n
#O(N^2)を防ぐために、穴判定用配列作る
for i in range(m):
  analist[a[i]-1]="ana"

for i in range(1,m):
  if a[i]-a[i-1]==1:
    print(0)
    sys.exit()
if 1 in a:
  nlist.append(0)
  nlist.append(1)
elif 2 in a:
  nlist.append(1)
  nlist.append(0)
else:
  nlist.append(1)
  nlist.append(2)

for i in range(2,n):
  if analist[i]=="ana":
    nlist.append(0)
  else:
    nlist.append((nlist[i-1]+nlist[i-2])%1000000007)
print(nlist[n-1]%1000000007)

Measured memory_bytes: 8184
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
//repマクロ定義
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
//allマクロ定義
#define all(v) v.begin(),v.end()
using namespace std;

int main(){
  int n; cin >> n;
  char s;
  for(int i=0;i<n;i++){
    cin >> s;
    if(s=='Y') {
      puts("Four");
      return 0;
    }
  }

  puts("Three");


}

Measured memory_bytes: 256
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//数値計算 個数以外はdouble
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
//同じ作業繰り返す系の問題：収束先を見つける
//過半数：N/2.0で判定
//優先度付きキュー
//priority_queue<
//ll,
//vector<ll>
//> q;
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll MOD = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

//a,bの最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1));
}

//Nのd桁目の数
ll dignum(ll N, ll d) {
	ll x = pow(10, d);
	N %= x;
	ll y = pow(10, d - 1);
	N /= y;
	return N;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

int main() {
	ll N, M, X; cin >> N >> M >> X;
	vector<ll> C(N);
	ll A[N][M];
	rep(i, N) {
		cin >> C[i];
		rep(j, M) {
			cin >> A[i][j];
		}
	}

	
	ll inf = 1e9;
	ll ans = inf;
	rep(s, 1 << N) {
		ll cost = 0;
		vector<ll> d(M);
		rep(i, N) {
			if (s >> i & 1) {
				cost += C[i];
				rep(j, M) d[j] += A[i][j];
			}
		}
		bool ok = true;
		rep(j, M) if (d[j] < X) ok = false;
		if (ok) ans = min(ans, cost);
	}

	if(ans == inf)cout << -1 << endl;
	else cout << ans << endl;
}

Measured memory_bytes: 11012
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
using namespace std;

unsigned long long gcd(long long a, long long b) {
    if (b == 0)
        return a;
    else 
        return gcd(b, a % b);
}

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

int main()
{
    int N;
    cin >> N;
    vector<unsigned long long> T(N);
    REP (i, N)
        cin >> T[i];

    unsigned long long ans = 1;
    REP (i, N) {
        ans = lcm(ans, T[i]);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
/*
[ ( ^ _ ^ ) ]
*/
// problem: atc/arc103_c
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1000000000



int main() {
    int n;
    scanf("%d", &n);
    vector<int> a(n);
    for(int i=0; i<n; i++) {
        scanf("%d", &a[i]);
    }
    map<int, int> mp;
    for(int i=0; i<n; i+=2) {
        mp[a[i]]++;
    }
    int mx1=0, mx2=0, vx1=0, vx2=0;
    map<int, int> mp2;
    for(int i=1; i<=n; i+=2) {
        mp2[a[i]]++;
    }
    for(auto kv: mp2) {
        int k = kv.first, v = kv.second;
        if(v>mx1) {
            mx2 = mx1, vx2 = vx1;
            mx1 = v, vx1 = k;
        } else if(v>mx2) {
            mx2 = v, vx2 = k;
        }
    }
    int rs = n;
    for(int i=1; i<=100000; i++) {
        int x = 0;
        if(mp.find(i) != mp.end()) {
            x += mp[i];
        }
        if(i==vx1) {
            x += mx2;
        } else {
            x += mx1;
        }
        x = n - x;
        rs = min(rs, x);
    }
    printf("%d\n", rs);
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
int main(){
	int t=1;
	//cin >> t;
	while(t--){
		int i=0,x=0,y=0;
      cin >> x >> y;
      	if(y%2==0&&2*x<=y&&y<=4*x){cout << "Yes"<<endl;}
      	else cout << "No"<<endl;
	}
}

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

using namespace std;

#define int long long
#define INF 1e9
#define LINF 1e18

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;
typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int N, h[100001];
int dp[100001];

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

    cin >> N;
    for(int i = 0; i < N; ++i) cin >> h[i + 1];
    dp[1] = 0;
    dp[2] = abs(h[2] - h[1]);
    dp[3] = min(dp[2] + abs(h[3] - h[2]), abs(h[3] - h[1]));
    for(int i = 4; i <= N; ++i) {
        dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1]));
    }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 1792
def dfs(balls, i, b, c)
  return true if i == balls.size
  return true if balls[i] > b && dfs(balls, i + 1, balls[i], c)
  return true if balls[i] > c && dfs(balls, i + 1, b, balls[i])
  return false
end

n = gets.to_i
n.times do
  balls = gets.split(' ').map(&:to_i)
  puts dfs(balls, 0, 0, 0) ? 'YES' : 'NO'
end

Measured memory_bytes: 6100
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
int const INF = 1001001001;


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

int x;
cin >> x;

if(x < 1200) puts("ABC");
else puts("ARC");

return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int i, x[10];
	int ans;
	for (i = 0; i < 5; i++) {
		cin >> x[i];
		if (x[i] == 0) {
			ans = i + 1;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3612
// 

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <stack>
#include <cstring>

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

using namespace std;

int main(){
    string s, c, w;
    int q, t, f;
    int cnt = 0;
    bool flg = false;

    cin >> s;
    cin >> q;
    for(int i = 0; i < q; i++){
        // cout << s << endl;
        cin >> t;
        if(t == 1){
            flg = !(flg);
            continue;
        }
        cin >> f;
        cin >> c;
        if(f == 1){
            if(flg){
                s += c;
            }else{
                w += c;
            }
        }else{
            if(flg){
                w += c;
            }else{
                s += c;
            }
        }
    }
    if(flg){
        reverse(s.begin(), s.end());
        cout << s << w << endl;
    }else{
        reverse(w.begin(), w.end());
        cout << w << s << endl;
    }
    return 0;
}


Measured memory_bytes: 964
#include <iostream>
#include <set>
#include <map>
#include <vector>

using namespace std;

bool not_zero[10];
int coefficient[10];

struct S {
  int value, used;
  S(int value, int used) : value(value), used(used) {}
  bool operator<(const S& s) const {
    return value != s.value ? value < s.value : used < s.used;
  }
};

void Dfs(int depth, int alphabet_size, int used, int lr, map<S, int>& m) {
  if (depth == alphabet_size) {
    ++m[S(lr, used)];
  } else {
    for (int i = not_zero[depth] ? 1 : 0; i < 10; ++i) {
      if (used & (1 << i)) continue;
      Dfs(depth + 1, alphabet_size, used | (1 << i), lr + coefficient[depth] * i, m);
    }
  }
}

int main() {
  int N;
  while (cin >> N, N) {
    vector<string> v(N);
    set<char> alph;
    for (int i = 0; i < N; ++i) {
      cin >> v[i];
      for (int j = 0; j < v[i].size(); ++j)
        alph.insert(v[i][j]);
    }

    string alphabet(alph.begin(), alph.end());

    vector<vector<int> > words(N);
    for (int i = 0; i < v.size(); ++i)
      for (int j = 0; j < v[i].size(); ++j)
        words[i].push_back(alphabet.find(v[i][j]));

    fill(coefficient, coefficient + 10, 0);
    for (int i = 0; i < N - 1; ++i)
      for (int j = words[i].size() - 1, ten = 1; j >= 0; --j, ten *= 10)
        coefficient[words[i][j]] += ten;
    for (int i = words.back().size() - 1, ten = 1; i >= 0; --i, ten *= 10)
      coefficient[words.back()[i]] -= ten;

    fill(not_zero, not_zero + 10, false);
    for (int i = 0; i < v.size(); ++i)
      if (v[i].size() > 1)
        not_zero[alphabet.find(v[i][0])] = true;

    map<S, int> head;
    Dfs(0, alphabet.size() / 2, 0, 0, head);
    map<S, int> tail;
    Dfs(alphabet.size() / 2, alphabet.size(), 0, 0, tail);

    vector<pair<S, int> > h(head.begin(), head.end());
    vector<pair<S, int> > t(tail.rbegin(), tail.rend());

    int answer = 0;
    for (int i = 0, j = 0; i < h.size() && j < t.size();) {
      int hv = h[i].first.value, tv = t[j].first.value, value = hv + tv;
      if (value < 0) {
        ++i;
      } else if (value > 0) {
        ++j;
      } else {
        for (int k = i; k < h.size() && h[k].first.value == hv; ++k) {
          for (int l = j; l < t.size() && t[l].first.value == tv; ++l) {
            if ((h[k].first.used & t[l].first.used) == 0) {
              answer += h[k].second * t[l].second;
            }
          }
        }
        while (i < h.size() && h[i].first.value == hv) ++i;
        while (j < t.size() && t[j].first.value == tv) ++j;
      }
    }
    cout << answer << endl;
  }
}

Measured memory_bytes: 7224
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int n,m,h[100100],bad[100100],a,b,num;
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		cin>>h[i];
	for(int i=1;i<=m;i++){
		cin>>a>>b;
		if(h[b]<=h[a])
			bad[b]=1;
		if(h[a]<=h[b])
			bad[a]=1;
	}
	for(int i=1;i<=n;i++)
		num-=bad[i];
	num+=n;
	cout<<num<<endl;
	return 0;
}


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

int main()
{
    long long k;
    scanf("%lld", &k);
    const long long quo = k / 50, rest = k % 50;
    printf("50\n");
    for (int i = 49; i >= 0; i--)
    {
        if (i != 49) printf(" ");
        if (i < rest) printf("%lld", quo + 50 - i);
        else printf("%lld", quo + 49 - i);
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 256
S = input()
mae = int(S[:2])
ato = int(S[2:])

def my(x):
    if x == 0:
        return "y"
    if x >= 13:
        return "y"
    return "my"

t = (my(ato),my(mae))
if t==("my","my"):
    print("AMBIGUOUS")
elif t== ("y","y"):
    print("NA")
elif t== ("y","my"):
    print("MMYY")
else:
    print("YYMM")

Measured memory_bytes: 38384
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main(){
    let k = read::<u32>();

    let mut cur = 0;
    let mut cur10 = 1;
    for kk in 0..k {
        cur = (cur + cur10*(7u32%k))%k;
        cur10 = (cur10*10u32)%k;
        if cur==0{
            println!("{}", kk+1);
            break
        }
    }
    if cur != 0{
        println!("{}", -1);
    }
    

    
}

Measured memory_bytes: 2124
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 1000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
typedef pair<int, int> P;
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    int A[200010], B[200010];
    cin >> N;
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    int ans = 0;
    while(true) {
        bool change = false;
        rep(i, N) {
            if(A[i] == B[i]) continue;
            int a = B[(i - 1 + N) % N];
            int b = B[i];
            int c = B[(i + 1) % N];
            int ok = 0;
            int ng = INF;
            while(abs(ok - ng) > 1) {
                int mid = (ok + ng) / 2;
                if(b - (a + c) * mid >= A[i]) ok = mid;
                else ng = mid;
            }
            if(ok == 0) continue;
            change = true;
            B[i] = b - (a + c) * ok;
            ans += ok;
        }
        // rep(i, N) cout << B[i] << " ";
        // cout << endl;
        if(!change) break;
    }
    rep(i, N) {
        if(A[i] != B[i]) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 6764
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
typedef long long int li;
const ll MAXN=102,MOD=998244353;
ll length;
ll pw[MAXN],prefix[MAXN],suffix[MAXN];
char s[MAXN],t[MAXN];
inline ll read()
{
    register ll num=0,neg=1;
    register char ch=getchar();
    while(!isdigit(ch)&&ch!='-')
    {
        ch=getchar();
    }
    if(ch=='-')
    {
        neg=-1;
        ch=getchar();
    }
    while(isdigit(ch))
    {
        num=(num<<3)+(num<<1)+(ch-'0');
        ch=getchar();
    }
    return num*neg;
}
int main()
{
	length=read(),scanf("%s%s",s,t),pw[0]=1,prefix[0]=t[0]-'a';
	for(register int i=1;i<length;i++)
	{
		pw[i]=(li)pw[i-1]*26%MOD;
		prefix[i]=(t[i]-'a'+(li)prefix[i-1]*26%MOD)%MOD;
	}
	for(register int i=length-1,j=0;i>=0;i--,j++)
	{
		suffix[i]=(suffix[i+1]+(li)pw[j]*(s[i]-'a')%MOD)%MOD;
	}
	for(register int i=0,j=length-1;i<length;i++,j--)
	{
		if(suffix[i]==prefix[j])
		{
			return printf("%d\n",(length<<1)-j-1),0;
		}
	}
	printf("%d\n",length<<1);
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <random>
#include <time.h>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807

//A
/*
int main() {

	

	return 0;
}
*/

//B
/*
int main() {



	return 0;
}
*/

//C

int main() {

	int n;
	cin >> n;
	int a1[100005] = {};
	int m1 = 0;
	int p1 = 0;
	int a2[100005] = {};
	int m2 = 0;
	int p2 = 0;
	for (int i = 0; i < n; i++) {
		int tmp;
		cin >> tmp;
		if (i % 2 == 0) {
			a1[tmp]++;
			if (a1[tmp] > m1) {
				m1 = a1[tmp];
				p1 = tmp;
			}
		}
		if (i % 2 == 1) {
			a2[tmp]++;
			if (a2[tmp] > m2) {
				m2 = a2[tmp];
				p2 = tmp;
			}
		}
	}
	if (p1 == p2) {
		int M1 = 0;
		int M2 = 0;
		for (int i = 0; i <= 100000; i++) {
			if (i == p1) continue;
			M1 = max(M1, a1[i]);
			M2 = max(M2, a2[i]);
		}
		cout << n - max(m1 + M2, m2 + M1) << endl;
	}
	else {
		cout << n / 2 - m1 + n / 2 - m2 << endl;
	}
	

	return 0;
}


//D
/*
int main() {



return 0;
}
*/

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

const int _ = 1e6 + 7;
char str[_] , tmp[_]; int L , cnt[3] , id[3];

void change(){
	for(int i = 0 ; i < 3 ; ++i) id[i] = i;
	for(int i = 1 ; i <= L ; ++i) ++cnt[str[i] - 'A'];
	sort(id , id + 3 , [&](int x , int y){return cnt[x] < cnt[y];});
	for(int i = 1 ; i <= L ; ++i)
		for(int j = 0 ; j < 3 ; ++j)
			if(str[i] - 'A' == id[j]){str[i] = 'A' + j; break;}
}

void output(char c){putchar(id[c - 'A'] + 'A');}
void output(string &str){for(auto t : str) output(t);}

#define PII pair < int , int >

int main(){
	scanf("%s" , str + 1);
	for(int i = 1 ; str[i] ; ++i) if(str[i] != tmp[L]) tmp[++L] = str[i];
	memcpy(str , tmp , sizeof(tmp)); change();
	int b1 = 0 , b2 = 0 , c1 = 0 , c2 = 0 , pre = 0; str[L + 1] = 'A';
	for(int i = 1 ; i <= L + 1 ; ++i)
		if(str[i] == 'A'){
			if(pre + 1 <= i - 1)
				if((i - 1) - (pre + 1) >= 1){++b1; ++c1;}
				else if(str[i - 1] == 'B'){++b1; ++b2;}
				else{++c1; ++c2;}
			pre = i;
		}
	vector < string > arr; string tparr; bool flg = 0;
	if(str[L] != 'A' && str[L - 1] == 'A')
		if(str[L] == 'B' && b2 > c1){--b2; L -= 2; flg = 1;}
		else if(str[L] == 'C' && c2 > b1){--c2; L -= 2; flg = 1;}
	for(int i = 1 ; i <= L + 1 ; ++i)
		if(str[i] == 'A')
			if(tparr.size() == 1)
				if(tparr[0] == 'B' && b2 > c1){
					--b2; if(i == 2){arr.push_back(tparr = ""); pre = i;}
					continue;
				}
				else if(tparr[0] == 'C' && c2 > b1){
					--c2; if(i == 2){arr.push_back(tparr = ""); pre = i;}
					continue;
				}
				else{arr.push_back(tparr); tparr = "";}
			else{arr.push_back(tparr); tparr = "";}
		else if(tparr.empty() || str[i] != *--tparr.end()) tparr.push_back(str[i]);
	if(flg) arr.push_back("");
	if(arr.size() == 1) return 0;
	int na = arr.size() - 1 , nb = 0 , nc = 0;
	for(auto t : arr) for(auto p : t) p == 'B' ? ++nb : ++nc;
	for(int i = 0 ; i < arr.size() ; ++i){
		if(i) output('A');
		string str = arr[i];
		if(str.size() >= 2){
			if(nb > nc && *str.begin() == 'B'){--nb; str.erase(str.begin());}
			if(nb > nc && *--str.end() == 'B'){--nb; str.erase(--str.end());}
			if(nb < nc && *str.begin() == 'C'){--nc; str.erase(str.begin());}
			if(nb < nc && *--str.end() == 'C'){--nc; str.erase(--str.end());}
			while(min(nb , nc) > na && (str.size() > 2 || (i == 0 || i + 1 == arr.size()) && str.size() >= 2)){
				str.erase(--str.end()); str.erase(--str.end());
				--nb; --nc;
			}
		}
		output(str);
	}
	return 0;
}

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

int main() {
  char b;
  cin >> b;
  if(b=='A') {
    cout << "T" << endl;
  }
  else if(b=='T') {
    cout << "A" << endl;
  }
  else if(b=='G') {
    cout << "C" << endl;
  }
  else {
    cout << "G" << endl;
}
}


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

using namespace std;

void solve() {
    int N;
    cin >> N;
    vector<pair<pair<string, int>, int>> p(N);
    string S;
    int P;
    for (int i = 0; i < N; i++) {
        cin >> S >> P;
        p[i] = make_pair(make_pair(S, -P), i+1);
    }
    sort(p.begin(), p.end());
    for (int i = 0; i < N; i++) {
        cout << p[i].second << endl;
    }
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 3600
import math
from fractions import gcd

a,b = map(int,input().split())
g = gcd(a,b)
gr = int(math.ceil(math.sqrt(g)))

facs = [1]
i = 2
while i*i <= g:
    if g == 1:
        break
    if g % i == 0:
        facs.append(i)
        while g % i == 0:
            g //= i
    i += 1
if g != 1:
    facs.append(g)

print(len(facs))


Measured memory_bytes: 65640
#include<stdio.h>
int main(void) {
    int n, w[100],i,j,tmp,mass;
    scanf("%d",&n);
    for(i = 0; i < n; i ++) {
        scanf("%d",&w[i]);
    }
    mass = 100000000;
    for(i = 0; i < n; i++) {
        tmp = 0;
        for(j = 0; j <i; j++) {
            tmp += w[j];
        }
        for(j = i; j < n; j++) {
            tmp -= w[j];
        }
        if(tmp < 0) {tmp *= -1;}
        if(mass > tmp) {mass = tmp;}
    }
    printf("%d\n", mass);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define ALL(x) (x).begin(),(x).end()
const long long MOD = 1000000007;
const long long INF = 1LL << 60;


int main(){
	int H, W;
	cin >> H >> W;
	int Scnt = 0;
	rep(i, H * W){
		char S;
		cin >> S;
		if(S == '#')Scnt++;
	}
	cout << ((Scnt == H + W - 1) ? "Possible" : "Impossible") << endl;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

vint v;
ll K;
vvint vv;
vint use;

ll dfs(int x, int d){
	if(vv[x].size() == 0){
		return K-2;
	}
	ll ret = INFL;
	for(int y:vv[x]){
		mins(ret,dfs(y,d+1));
	}
	if(ret == 0 && v[x] != 0){
		use[x] = 1;
		return K-1;
	}
	return ret-1;
}


void mainmain(){
	int n;
	cin>>n;
	cin>>K;
	v=vint(n);
	use=vint(n,0);
	vv=vvint(n);
	rep(i,n){
		cin>>v[i];
		v[i]--;
		if(i) vv[v[i]].PB(i);
	}
	int ans = 0;
	if(v[0] != 0){
		v[0] = 0;
		use[0]=1;
	}
	if(K == 1){
		rep(i,n){
			if(v[i] != 0) use[i] = 1;
		}
		rep(i,n){
			if(use[i]) ans++;
		}
		cout<<ans<<endl;
		return;
	}
	dfs(0,0);
	rep(i,n){
		if(use[i]) ans++;
	}
	cout<<ans<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 11264
n=int(input())

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True
  
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
if is_prime(n):
  print(n-1)
  exit()
  
#print(make_divisors(n))
div=make_divisors(n)
l=[]
for i in div:
  ii=n//i
  l.append(ii+i)

print(min(l)-2)


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

int main(){
    int N, K, ans=0, L=0, R=0, tmp;
    string s;
    cin >> N >>K;
    cin >> s;
    if(s[0] == 'L')
	L++;
    else
	R++;

    for(int i=0; i<N; i++){
	if(s[i]==s[i+1])
	    ans++;
	if(s[i]=='R' && s[i+1]=='L')
	    L++;
	if(s[i]=='L' && s[i+1]=='R')
	    R++;
    }
    tmp = min(L, R);
    while(true){
	if(K==0 || tmp==0)
	    break;
	if(ans == N-2)
	    ans ++;
	else
	    ans += 2;
	tmp--;
	K--;
    }
    cout << ans << endl;
}



Measured memory_bytes: 512
# 1 "d.cpp"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "d.cpp"
# 1 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 1
       
# 12 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp"
# 1 "/home/tysm/dev/cpplib/bin/../stdlib/bits/stdc++.h" 1
 #include <bits/stdc++.h>
# 13 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 2
# 1 "/home/tysm/dev/cpplib/bin/../stdlib/ext/pb_ds/assoc_container.hpp" 1
 #include <ext/pb_ds/assoc_container.hpp>
# 14 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 2
# 1 "/home/tysm/dev/cpplib/bin/../stdlib/ext/pb_ds/tree_policy.hpp" 1
 #include <ext/pb_ds/tree_policy.hpp>
# 15 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 2







using namespace std;
using namespace __gnu_pbds;

using ii = pair<long long, long long>;
using vi = vector<long long>;
using vd = vector<long double>;
using vb = vector<bool>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vvd = vector<vd>;
using vvb = vector<vb>;
using vvii = vector<vii>;
# 50 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp"
inline long long mod(const long long n, const long long m = ((long long)1e9+7)){
    return (n%m + m)%m;
}

/**
 * Euclidean GCD.
 *
 * Time Complexity: O(log(min(a, b))).
 * Space Complexity: O(log(min(a, b))).
 */
long long gcd(const long long a, const long long b){
    if(a < 0 or b < 0)
        return gcd(abs(a), abs(b));
    if(a == 0)
        return b;
    return gcd(b%a, a);
}

/**
 * Euclidean derivated LCM.
 *
 * Time Complexity: O(log(min(a, b))).
 * Space Complexity: O(log(min(a, b))).
 */
long long lcm(const long long a, const long long b){
    // same as a*b/gcd(a, b) but avoiding overflow.
    return a/gcd(a, b)*b;
}
# 2 "d.cpp" 2

int32_t main(){
    (ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL));
    long long n;
    cin >> n;
    vi arr(n), cnt(((long long)1e6+1));
    for(long long &i:arr){
        cin >> i;
        cnt[i]++;
    }
    long long ans = 0;
    for(long long i:arr){
        cnt[i]--;
        bool valid = true;
        for(long long j=1; j*j<=i; ++j){
            if(i%j)
                continue;
            if(cnt[j] or cnt[i/j])
                valid = false;
        }
        ans += valid;
        cnt[i]++;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 12704
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] h = new int[n + 1];
      for (int i = 1; i <= n; i++) h[i] = sc.nextInt();
      int[] dp = new int[n + 1];
      Arrays.fill(dp,1,n + 1, Integer.MAX_VALUE);
      dp[1] = 0;
      for (int i = 1; i < n; i++){
        if (i + 2 <= n) {
          dp[i + 2] = Math.min(dp[i + 2], dp[i] + Math.abs(h[i] - h[i + 2]));
        }
        dp[i + 1] = Math.min(dp[i + 1], dp[i] + Math.abs(h[i] - h[i + 1]));

      }
      System.out.println(dp[n]);
  }
}


Measured memory_bytes: 50692
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;
 
int main(){
  int a,b,t;
  cin >> a >> b >>t;

  int ans = 0;
  int d = t/a;
  
  ans = b*d;
  
  cout << ans << endl;
 
  return 0;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
int main()
{
    long long int n,p,q,r,cur,i,j,k,x,y,z,c1=0,c2=0,c3=0,f=0;
    //cin>>n>>k;
    //map<long long int,long long int>m;
    //vector<long long int>v;
    set<long long int>s;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>x;
        s.insert(x);
    }
    cout<<s.size()<<endl;
    return 0;
}




Measured memory_bytes: 256
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.Collections;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// 標準入力の読み込み開始
        Scanner scanner = new Scanner(System.in);

        // 数列の長さ
        int n = scanner.nextInt();

        // 数列
        List<Integer> numList = new ArrayList<Integer>();
        for (int i = 0; i < n; i++) {
            numList.add(scanner.nextInt());
        }

        // 標準入力の読み込み終了
        scanner.close();
        
        int minj = 0;
        int cnt = 0;
		for (int i = 0; i < n; i++) {
			minj = i;
			
			for (int j = i; j < n; j++) {
				if (numList.get(j) < numList.get(minj)) {
					minj = j;
				}
			}
			//A[i] と A[minj] を交換
			if (i < minj) {
				Collections.swap(numList, i, minj);
				cnt++;
			}
		}
		
		// 出力
		StringBuilder sb = new StringBuilder();
		for(int i = 0; i < n; i++){
			sb.append(numList.get(i));
			if(i < n - 1){
	    			sb.append(" ");
			}
		}
		System.out.println(sb);
		
		System.out.println(cnt);
	}
}


Measured memory_bytes: 26360
n, m = map(int, input().split())
l = list(map(int, input().split()))
sl = sorted(l, reverse=True)
check = []
for i in range(m):
    if sl[i] < sum(sl) / (4 * m):
        check.append('No')
    else:
        check.append('Yes')
print('No' if 'No' in check else 'Yes')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
int a[1005];
int main() {
  int n;
  cin >> n;
  for (int i = 2; i <= n; i++) {
    int t = i;
    for (int j = 2; j <= i; j++) {
      while (t % j == 0) {
        t /= j;
        a[j]++;
      }
    }
  }
  long long ans = 1;
  for (int i = 2; i <= n; i++) {
    ans *= a[i] + 1;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}


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

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define FORV(a, A) for (auto &a : A)

using namespace std;
using ll = long long;
using P = pair<int, int>;

void Main() {
  string s, t;
  cin >> s >> t;
  cout << t << s << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  // 数列Aを、狭義短調増加の複数の数列に分ける際、最低いくつの数列になるか

  int N;
  cin >> N;
  multiset<int> as;
  F0R(i, N) {
    int a;
    cin >> a;

    auto it = as.lower_bound(a);
    if (it != as.begin()) {
      as.erase(--it);
    }
    as.insert(a);
  }
  cout << as.size();
}
#endif


Measured memory_bytes: 8284
N,K=map(int,input().split())
p=list(map(int,input().split()))

A=[]
base=0
B=[]

for i in range(N):
    if p[i]%2==0:
        A.append(((p[i]+1)*p[i]//2)/p[i])
    else:
        A.append((((p[i]+1)*(p[i]//2)+((p[i]+1)//2)))/p[i])
    
for l in range(K):
    base+=A[l]
B.append(base)
for k in range(K,N):
    base+=A[k]
    base-=A[k-K]
    B.append(base)    

print(max(B))
#print(A)


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

int main() {
  string S,T;
  int A,B;
  cin >> S >> T >> A >> B;
  
  string U;
  cin >> U;
  
  if (U == S){
    cout << A-1 << " " << B << endl;
  } else {
    cout << A << " " << B-1 << 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 n;
    cin >> n;
    vector<long long int> L(n + 1);

    L[0] = 2;
    L[1] = 1;
    for(int i = 2; i < n + 1; i++) {
        L[i] = L[i - 1] + L[i - 2];
    }

    cout << L[n] << endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B;
  if(A == 1 && B ==1) cout << "Draw" << endl;
  else if (A == 1) cout << "Alice" << endl;
  else if (B == 1) cout << "Bob" << endl;
  else if (A - B > 0) cout << "Alice" << endl;
  else if (A - B == 0) cout << "Draw" << endl;
  else cout << "Bob" << endl;
}

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

int main(){
    long long a, b, c;
    cin >> a >> b >> c;
    if (c - a - b < 0) {
        cout << "No";
        return 0;
    }
    
    cout << ((4*a*b < (c-a-b)*(c-a-b)) ? "Yes" : "No");
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

string str;
int cnt[3];

int main(void){
	cin >> str;
	for(int i=0;i<str.size();i++){
		cnt[(str[i]-'a')]++;
	}
	sort(cnt,cnt+3);
	bool flag=true;
	if(cnt[2]-cnt[0]>=2)flag=false;
	printf("%s\n",flag?"YES":"NO");
	return 0;
}

Measured memory_bytes: 512
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]

dp = [-1]*(N+1)
for i in a:
    dp[i] = 0

dp[0] = 1
mod = 1000000007

for i in range(1, N+1):
    if dp[i] == 0:
        continue
    else:
        if i > 1:
            dp[i] = (dp[i-1] + dp[i-2])
        else:
            dp[i] = dp[i-1]

print(dp[-1] % mod)


Measured memory_bytes: 460020
import bisect
 
n=int(input())
a=list(map(int,input().split()))
a=sorted(a)
ans=0
for i in range(n-2):
    for j in range(i+1,n-1):
        tmp=a[i]+a[j]
        index=bisect.bisect_left(a,tmp)
        ans+=index-j-1
print(ans)

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

int main(void){
    int k;
    vector<int> a = {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};
    cin >> k;
    cout << a[k-1] << endl;
    return 0;
}

Measured memory_bytes: 256