akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
s = input()
t = input()
s_idx = [[] for _ in range(26)]
t_idx = [[] for _ in range(26)]
for i in range(len(s)):
    s_idx[ord(s[i])-97].append(i)
visit = []
for i in range(26):
    cnt = 0
    for j in s_idx[i]:
        if cnt == 0 and t[j] in visit:
            print("No")
            exit()
        if cnt == 0:
            visit.append(t[j])
            cnt += 1
        else:
            if t[j] != visit[-1]:
                print("No")
                exit()
print("Yes")
        

        

Measured memory_bytes: 52560
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i) 
const int N = 2005, mo = 1e9 + 7 ;
using namespace std ;
int H, W ; ll k ;
char a[N][N] ;
void upd(int &x, int y) { x = (x + y) % mo ; }
void mul(int A[2][2], int B[2][2], int (&C)[2][2]) {
	rep(i, 0, 1) rep(j, 0, 1) C[i][j] = 0 ;
	rep(i, 0, 1) rep(j, 0, 1) rep(k, 0, 1) upd(C[i][j], (ll) A[i][k] * B[k][j] % mo) ;
}
int ksm(int a, ll b) {
	int ans = 1, w = a % mo ;
	for ( ; b ; b /= 2) {
		if (b & 1LL) ans = (ll) ans * w % mo ;
		w = (ll) w * w % mo ;
	}
	return ans ;
}
int main() {
	scanf("%d%d%lld", &H, &W, &k) ;
	if (k < 2LL) { puts("1") ; return 0 ; } k -= 2 ;
	int tx = 0, ty = 0, w[2][2] = {0}, ans[2][2] = {0}, tmp[2][2], x, y ;
	rep(i, 1, H) scanf("%s", a[i] + 1) ;
	rep(i, 1, H) if (a[i][1] == '#' && a[i][W] == '#') ++ tx ;
	rep(i, 1, W) if (a[1][i] == '#' && a[H][i] == '#') ++ ty ;
	rep(i, 1, H) rep(j, 1, W) if (a[i][j] == '#') ++ w[0][0] ;
	if (tx && ty) { puts("1") ; return 0 ; } 
	if (!tx && !ty) { printf("%d\n", ksm(w[0][0], k + 1)) ; return 0 ; }
	if (tx) {
		rep(i, 1, H) rep(j, 1, W - 1) if (a[i][j] == '#' && a[i][j + 1] == '#') ++ w[0][1] ;
		w[1][1] = tx ;
	} else {
		rep(i, 1, H - 1) rep(j, 1, W) if (a[i][j] == '#' && a[i + 1][j] == '#') ++ w[0][1] ;
		w[1][1] = ty ;
	}
	rep(i, 0, 1) rep(j, 0, 1) ans[i][j] = (i == j) ;
	x = w[0][0], y = w[0][1] ;
	for ( ; k ; k /= 2) {
		if (k & 1LL) {
			mul(ans, w, tmp) ;
			rep(i, 0, 1) rep(j, 0, 1) ans[i][j] = tmp[i][j] ;
		}
		mul(w, w, tmp) ;
		rep(i, 0, 1) rep(j, 0, 1) w[i][j] = tmp[i][j] ;
	}
	int X = (ll) x * ans[0][0] % mo + (ll) y * ans[1][0] % mo ; X %= mo ;
	int Y = (ll) x * ans[0][1] % mo + (ll) y * ans[1][1] % mo ; Y %= mo ;
	printf("%d\n", ((X - Y) % mo + mo) % mo) ;
	return 0 ;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef unsigned long long int ull;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ff first
#define ss second
#define pb push_back
#define Inf  1e18
#define inf -1e18
#define mod 1000000007
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll,ll>;
using umll = unordered_map<ll,ll>;
using sll = set<ll>;
using msll = multiset<ll>;
using pll = pair<ll,ll>;
 
ll MUL(ll A,ll B){
  return (A%mod*B%mod)%mod;
}
 
ll ADD(ll A,ll B){
  return (A%mod+B%mod)%mod;
}
 
ull power(ll A,ll B) {
    ull RES = 1;
    while (B > 0)
    {
        if (B & 1)
            RES = RES*A;
        B = B>>1;
        A = A*A;
    }
  return RES;
}
 
 const ll maxS = 2e5+10;
 ll n , m ;
 ll arr[maxS];
 

 
 
void testcases(int cases){
	string s,t;
	cin >> s>> t;
	int cnt = 0;
	for(int i =0 ;i <s.size(); i ++){
		if(s[i]!=t[i])
		cnt++;
	}
	cout << cnt << "\n";
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
    ll t;
    t = 1;
    //t = 1;
    ll Case =1 ;
    while(t--)
    {
      testcases(Case++);
    }
}


Measured memory_bytes: 3800
n = int(input())
p = list(map(int,input().split()))

ans = 0
for i in range(n-1):
    if p[i] == i+1:
        p[i],p[i+1] = p[i+1],p[i]
        ans += 1

for i in range(1,n):
    if p[i] == i+1:
        p[i],p[i-1] = p[i-1],p[i]
        ans += 1
print(ans)


Measured memory_bytes: 14008
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;
int main()
{
  int n;
cin >> n;
  
  vector<int> v;
  for(int i=0; i<n; i++)
  {
    int x;
    cin >> x;
    v.push_back(x);
  }
  
  sort(v.begin(), v.end());
  int d = v.size()/2-1;
  cout << v[d+1] - v[d] << endl;
  
  return 0;
}

Measured memory_bytes: 892
open Str
open Scanf

let id x = x

let read_array n =
  Array.init n (fun i -> if i = 0 then scanf "%d" id else scanf " %d" id)

let print_array a =
  Array.iteri (fun i x -> if i > 0 then print_string " " else (); print_int x) a; print_newline ()

let counting_sort a b k =
  let c = Array.make (k+1) 0 in
  let rec idx i =
    if i > k then () else
      begin c.(i) <- c.(i) + c.(i-1); idx (i+1) end in
  Array.iter (fun x -> c.(x) <- c.(x) + 1) a;
  idx 1;
  Array.iter (fun x -> let i = c.(x) - 1 in b.(i) <- x; c.(x) <- i) a

let () =
  let n = read_int () in
  let ar = read_array n in
  let res = Array.make n 0 in
  counting_sort ar res 10000;
  print_array res

Measured memory_bytes: 36196
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#define ll long long
#define ull unsigned long long
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define lowbit(x) (x& -x)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define eps 1e-18
#define maxn 300010
inline ll read(){ll tmp=0; char c=getchar(),f=1; for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1; for(;'0'<=c&&c<='9';c=getchar())tmp=(tmp<<3)+(tmp<<1)+c-'0'; return tmp*f;}
inline ll power(ll a,ll b){ll ans=0; for(;b;b>>=1){if(b&1)ans=ans*a%mod; a=a*a%mod;} return ans;}
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
using namespace std;
char s[maxn];
int sum[maxn];
int n;
int main()
{
	int i;
	n=read(); scanf("%s",s);
	sum[0]=0;
	for(i=1;i<=n;i++){
		sum[i]=sum[i-1];
		if(s[i-1]=='W')sum[i]++;
	}
	int ans=inf;
	for(i=1;i<=n;i++)ans=min(ans,sum[i-1]+((n-i)-(sum[n]-sum[i])));
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1664
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<set>
#include<map>
#define mod 1000000007
using namespace std;
int main(){
    char s[5];
    int a[26]={},ans=0;
    scanf("%s",s);
    for(int i=0;i<4;i++){
        a[s[i]-'A']++;
    }
    for(int i=0;i<26;i++){
        if(a[i]==2){
            ans++;
        }
    }
    if(ans==2){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
}

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

int main() {
    int A, B;
    cin >> A >> B;

    int count = 0;
    int remaind, reverse = 0;
    for(int a = 1; a < 10; a++) {
        for(int b = 0; b < 10; b++) {
            for(int c = 0; c < 10; c++) {
                int num = 10001*a + 1010*b + 100*c;
                if(num >= A && num <= B) {
                    count++;
                }  
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
int s[15][15];
int p[15];
int z[15];
int main()
{     
    int n,m;
    cin>>n>>m;
    for(int i=1; i<=m; i++)
    {
        int a;
        cin>>a;
        while(a--)
        {
            int b;
            cin>>b;
            s[i][b]=1;
        }
    }
    int ans=0;
    for(int i=1; i<=m; i++)
        cin>>p[i];
    for(int i=0; i<(1<<n); i++)
    {
        memset(z,0,sizeof(z));
        for(int j=0; j<n; j++)
        {
            if((1<<j)&i)
                z[j+1]=1;
        }
        int q=0;
        for(int j=1; j<=m; j++)
        {
            int pp=0;
            for(int k=1; k<=n; k++)
                if(s[j][k]&&z[k])
                    pp++;
            if(pp%2!=p[j])
                q=1;
        }
        if(!q)
            ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
    ll N, A, B;
    cin >> N >> A >> B;
    vector<ll> P(N);

    ll under_A = 0, over_B = 0;
    for (ll i = 0; i < N; i++) {
        cin >> P[i];
        if (P[i] <= A) {
            under_A++;
        } else if (P[i] > B) {
            over_B++;
        }
    }

    cout << min({under_A, over_B, N - under_A - over_B}) << endl;
}

Measured memory_bytes: 256
#coding: utf-8

S = input()
T = input()

match = len(T) 
for i in range(len(S) - len(T)+1):
    cand = len(T)
    for j in range(len(T)):
        if S[i+j] == T[j]:
            cand -= 1
    match = min(cand, match)

print(match)


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

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

typedef long long ll;
const ll MOD = 1e9 + 7;
const int MAX_N = 2500;
const int MAX_M = 5000;

const ll INF = 1LL << 31;

int main() {
  int N, M, P;
  static std::vector<std::pair<int, int>> dest[MAX_N], orig[MAX_N];

  std::cin >> N >> M >> P;
  rep(i, M) {
    int A, B, C;
    std::cin >> A >> B >> C;
    --A;
    --B;
    C = - (C - P);
    dest[A].push_back(std::make_pair(B, C));
    orig[B].push_back(std::make_pair(A, C));
  }

  static ll d[MAX_N];
  rep(i, N) d[i] = INF;
  d[0] = 0;
  rep(i_, N - 1) {
    rep(a, N) {
      for(auto e : dest[a]) {
        int b = e.first;
        int c = e.second;
        if(d[b] > d[a] + c) {
          d[b] = d[a] + c;
        }
      }
    }
  }

  int reachable_front[MAX_N] = {};
  reachable_front[0] = 1;
  std::queue<int> q;
  q.push(0);
  while(! q.empty()) {
    int a = q.front(); q.pop();
    for(auto e : dest[a]) {
      int b = e.first;
      if(reachable_front[b] == 1) continue;
      reachable_front[b] = 1;
      q.push(b);
    }
  }

  int reachable_back[MAX_N] = {};
  reachable_back[N - 1] = 1;
  q.push(N - 1);
  while(! q.empty()) {
    int b = q.front(); q.pop();
    for(auto e : orig[b]) {
      int a = e.first;
      if(reachable_back[a] == 1) continue;
      reachable_back[a] = 1;
      q.push(a);
    }
  }

  bool cand[MAX_N];
  rep(i, N) {
    cand[i] = reachable_front[i] == 1 && reachable_back[i] == 1;
  }

  bool loop = false;
  rep(a, N) {
    for(auto e : dest[a]) {
      int b = e.first;
      int c = e.second;
      if(not cand[a] or not cand[b]) continue;
      if(d[b] > d[a] + c) {
        loop = true;
        break;
      }
    }
    if(loop) break;
  }

  if(loop) {
    std::cout << -1 << '\n';
    return 0;
  } else {
    std::cout << std::max(0LL, - d[N - 1]) << '\n';
  }
}


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

int main(){

    vector<int> a;
    vector<bool> f(300000,true);
    for(int i=6;i<300000;i++){
        if(f[i]&&((i+1)%7==0||(i-1)%7==0)){
            a.push_back(i);
            for(int j=i+i;j<300000;j+=i){
                f[j]=false;
            }
        }
    }
    while(1){
        int n;
        cin >> n;
        if(n==1){
            break;
        }
        set<int> ans;
        for(int i=0;a[i]<=n&&i<a.size();i++){
            if(n%a[i]==0){
                ans.insert(a[i]);
            }
        }
        cout << n << ":";
        for(auto it=ans.begin();it!=ans.end();it++){
            cout << " " << *it;
        }cout  << endl;
    }

    return 0;
}


Measured memory_bytes: 3224
#include <cstdio>

template <class T>
T abs(T x) {
    return (x > 0) ? x : -x;
}

int main(int argc, const char * argv[]) {
    long xp0, xp1, xp2, yp0, yp1, yp2;
    int q;
    
    scanf("%ld %ld %ld %ld", &xp0, &yp0, &xp1, &yp1);
    scanf("%d", &q);
    
    long v1x = xp1 - xp0;
    long v1y = yp1 - yp0;
    
    for (int i = 0; i < q; ++i) {
        scanf("%ld %ld", &xp2, &yp2);
        long v2x = xp2 - xp0;
        long v2y = yp2 - yp0;
        
        long crossProd = v1x * v2y - v1y * v2x;
        
        if (crossProd > 0) {
            puts("COUNTER_CLOCKWISE");
        } else if (crossProd < 0) {
            puts("CLOCKWISE");
        } else if (v2x * v1x < 0 || v2y * v1y < 0) {
            puts("ONLINE_BACK");
        } else if (abs(v1x) < abs(v2x) || abs(v1y) < abs(v2y)){
            puts("ONLINE_FRONT");
        } else {
            puts("ON_SEGMENT");
        }
    }
    
    return 0;
}



Measured memory_bytes: 2680
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define popcnt(x) __builtin_popcount(x)
#define popcntll(x) __builtin_popcountll(x)

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

const double PI = acos(-1);
constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class Task{
public:
    int N;

    void run(){
        ios_base::sync_with_stdio(false);
        cin.tie(nullptr);
        cout.tie(nullptr);
        // input
        cin>>N;
        // solve
        solve();
    }

    void solve(){
        int x = -1;
        for(int i=1;i*i<=8*N+1;++i){
            if(i*i==8*N+1){
                x = i;
                break;
            }
        }
        if(x==-1){
            cout<<"No\n";
            return;
        }
        int k = (x+1) / 2, nxt = 1;
        vvc<int> S(k);
        for(int i=0;i<k;++i){
            for(int j=i+1;j<k;++j){
                S[i].push_back(nxt);
                S[j].push_back(nxt);
                ++nxt;
            }
        }
        cout<<"Yes\n";
        cout<<k<<'\n';
        REP(i, k){
            cout<<LEN(S[i]);
            for(auto& e : S[i]) cout<<' '<<e;
            cout<<'\n';
        }
    }
};

int main(){
    Task solver;
    solver.run();
    return 0;
}


Measured memory_bytes: 4196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = ll(1e9) + 7;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e5) + 5;
constexpr double EPS = 1e-9;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i > 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

ll n, a[3][2], ans;
vector<ll> dp[4];

int main() {
    cin >> n;
    REP(i,2)REP(j,3) cin >> a[j][i];

    REP(i,4) dp[i].resize(n+1);
    REP(i,4)REP(j,n+1) dp[i][j] = j;
    REP(i,3){
        REP(j,n+1){
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
            if(j+a[i][0] <= n){
                dp[i][j+a[i][0]] = max(dp[i][j+a[i][0]], dp[i][j]+a[i][1]);
            }
        }
    }
    n = dp[3][n];
    REP(i,4) dp[i].resize(n+1);
    REP(i,4)REP(j,n+1) dp[i][j] = j;
    REP(i,3){
        REP(j,n+1){
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
            if(j+a[i][1] <= n){
                dp[i][j+a[i][1]] = max(dp[i][j+a[i][1]], dp[i][j]+a[i][0]);
            }
        }
    }
    cout << dp[3][n] << endl;
    return 0;
}


Measured memory_bytes: 781696
#include <iostream>
#include<string>

using namespace std;
int main(){

    bool yn = false;
    string x;
    cin >> x;
    if(x.size()==6){
        if ((x[2]==x[3]) && (x[4]==x[5]))
            yn = true;
    }
    if (yn)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, d;
    int i, j, k;
    int arr[11][11];
    scanf("%d%d", &n, &d);
    for(i=0; i<n; i++){
        for(j=0; j<d; j++){
            scanf("%d", &arr[i][j]);
        }
    }
    int ans=0;
    for(i=0; i<n; i++){
        for(j=i+1; j<n; j++){
            int sum=0;
            for(k=0; k<d; k++){
                sum+=pow(abs(arr[i][k]-arr[j][k]), 2);
            }
            double testVal=sqrt(sum);
            //printf("%d and %d: %d\n", i, j, sum);
            if(testVal-(int)testVal==0.000){
                ans++;
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}


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

int main()
{
  int n, s, count, max, min, sum, adv;
  while(cin >> n){
    if(n == 0){
      break;
    }
    min = 1001;
    max = -1;
    sum = 0;
    count = 0;
    while(count < n){ 
      count++;
      cin >> s;
      sum += s;
      if(s < min){
        min = s;
      }
      if(s > max){
        max = s;
      }
    }
    sum = sum - max - min;
    adv = sum / (n - 2);
    cout << adv << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
 
using namespace std;
 
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
const int mod=1e9+7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename A,typename B> istream& operator>>(istream&,pair<A,B>&);
template<typename A> istream& operator>>(istream&,vector<A>&);
void inline add(int&,int);
int mul(int,int);
int powz(int,int);
int sub(int,int);
template<typename A> ostream& operator<<(ostream&,vector<A>&);
 
const int N=1000002;

void solve(){
	int k,x;
	cin>>k>>x;
	for(int i=x-k+1;i<x+k;i++)cout<<i<<' ';
	
}

 
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tc=1;
	//~ cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}
 
int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}
 
void inline add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
}
 
int sub(int a,int b){
	a-=b;
	if(a<0){
		a+=mod;
	}
	return a;
}
 
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)res=mul(res,a);
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
	    output<<i<<' ';
	return output;
}


Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var pqr = Console.ReadLine().Split();
        var p = int.Parse(pqr[0]);
        var q = int.Parse(pqr[1]);
        var r = int.Parse(pqr[2]);

        var ans = p + q + r - Math.Max(Math.Max(p, q), r);
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13140
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

typedef unsigned long long ull;
const ull B = 100000007;

string T;
string P;

int main(int argc, char** argv) {
  cin >> T;
  cin >> P;

  int ts = T.size();
  int ps = P.size();
  // NOTE: Early return
  if (ps > ts) return 0;

  // NOTE: calculate t = B ^ ps
  ull t = 1;
  for (int i = 0; i < ps; ++i) {
    t *= B;
  }

  ull th = 0;
  ull ph = 0;
  // NOTE: calculate for fist ps
  for (int i = 0; i < ps; ++i) {
    th = th * B + T[i];
  }
  for (int i = 0; i < ps; ++i) {
    ph = ph * B + P[i];
  }

  // NOTE: calculate result
  vector<int> r;
  for (int i = 0; i + ps <= ts; ++i) {
    if (ph == th) {  // NOTE: match `b[i] .. b[i + ps - 1]`
      r.push_back(i);
    }
    if (i + ps < ts) {
      th = th * B + T[i + ps] - T[i] * t;
    }
  }

  for (int i = 0; i < r.size(); ++i) {
    cout << r[i] << endl;
  }

  // NOTE: Only for debug
  // cout << T << endl;
  // cout << P << endl;
  return 0;
}



Measured memory_bytes: 8332
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from itertools import *
from copy import *

N = int(input())
p = list(map(float, input().split()))
dp = [[0] * (N+1) for i in range(N+1)]
dp[0][0] = 1
for i in range(N):
    for j in range(i+2):
        if j != 0:
            dp[i+1][j] += dp[i][j-1]*p[i]
        dp[i+1][j] += dp[i][j]*(1-p[i])
ans = 0
for i in range(N//2+1, N+1):
    ans += dp[N][i]
print(ans)


Measured memory_bytes: 258440
using System;
using static System.Console;

namespace abc175
{
    class Program
    {
        static void Main()
        {
            var xkd = ReadLine().Split(' ');
            var x = long.Parse(xkd[0]);
            var k = long.Parse(xkd[1]);
            var d = long.Parse(xkd[2]);

            x = Math.Abs(x);
            WriteLine(Math.Abs(WT(x, k, d)));
        }
        static long WT(long x, long k, long d)
        {
            var countBeforeOfuku = x / d;
            if (countBeforeOfuku >= k)
            {
                return x - k * d;
            }

            if ((k - countBeforeOfuku) % 2 == 1)
            {
                return x % d - d;
            }
            else
            {
                return x % d;
            }
        }
    }
}


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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define vi vector<int>
typedef long long ll;

using namespace std;


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

	int n , sum = 0;
	cin >> n;
	bitset<100100> v;
	v[0] = 1;
	rep(i , n){
		int s;
		cin >> s;
		sum += s;
	//	v[s] = 1;
		v |= v << s;
	}
	int ans = 0;
	repn(i , sum + 10){
		if(i % 10 == 0)continue;
		if(v[i])
			ans = max(ans , i);
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>

#define MAX_INT 2147483647
#define PI 3.141592653589793238462643383279502884L

#define long long long int

using std::vector;
using std::map;
using std::string;
using std::pair;
using std::cin;
using std::cout;
using std::cerr;

// @author: pashka

int main() {
    std::ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<bool> c(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        b[i] = 0;
        int x = 1;
        while (x < a[i]) {
            b[i]++;
            x *= 2;
        }
        c[i] = x == a[i];
    }
    int res = b[0];
    for (int i = 0; i < n - 1; i++) {
        if (b[i + 1] > b[i]) {
            res += (b[i + 1] - b[i]);
        }
    }
    for (int i = 1; i < n - 1; i++) {
        if (!c[i] && b[i] <= b[i - 1] && b[i] <= b[i + 1]) {
            c[i + 1] = true;
            res++;
        }
    }

    cout << res << "\n";
    return 0;
}

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

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

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

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n);
    vc<pair<int, int>> p(n);
    For(i, n) cin >> p[i].first >> p[i].second;
    DeSort(p);
    Cout(p[0].first + p[0].second);
}





Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//cout << fixed << setprecision(17) << res << endl;
 
int main() {
    ll n;
    cin >> n;
    string s = "";

    while (n != 0) {
        ll r = n % 2;
        if (r < 0) r += 2;

        n = (n-r) / (-2);
        s += (char)('0' + r);
    }
    if (s == "") s = "0";
    reverse(s.begin(), s.end());
    cout << s << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main() {
	int n,k=0,b;
	vector <int> L;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>b;
		L.push_back(b);
	}
    int ans = 0;
    for(int i = 0; i < n - 2; i++){
        for(int j = i + 1; j < n - 1; j++){
            for(int k = j + 1; k < n; k++){
                if(L[i] != L[j] && L[j] != L[k] && L[k] != L[i]){
                    if(L[i] + L[j] > L[k] && L[j] + L[k] > L[i] && L[i] + L[k] > L[j]){
                        ans++;
                    }
                }
            }
        }
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3140
n=int(input())
v=list(map(int,input().split()))
c=list(map(int,input().split()))
a=[]
for i in range(n):
    x=v[i]
    y=c[i]
    a.append(x-y)

def max_sum(N,a):
  dp=[0]*(N+1)
  for i in range(N):
    dp[i+1]=max(dp[i],dp[i]+a[i])
  return dp[N]

print(max_sum(n,a))


Measured memory_bytes: 38256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
*/public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}
static class TaskD   {
int[][] bA;
int N;
long memo[] = new long[50];

public void solve(int testNumber, Scanner in, PrintWriter out) {
        N = in.nextInt();
        long K = in.nextLong();
        long A[] = new long[N];
        for (int i=0; i<=N-1; i++) {
            A[i] = in.nextLong();
        }

        bA = new int[40][2];
        for (int i=0; i<=N-1; i++) {
            long ac = A[i];
            for (int j=0; ac > 0; j++) {
                bA[j][0] += ac % 2;
                ac /= 2;
            }
        }

        long kc = K;
        int keta = 0;
        for (int i=0; kc > 0; i++){
            bA[i][1] = (int)(kc%2);
            kc /= 2;
            keta++;
        }


        long ans = dfs(keta, false);


        for (int i=keta; i<=39; i++) {
            ans += pow(2, i) * bA[i][0];
        }
        out.println(ans);
    }

long dfs(int n, boolean free) {
        long ret = 0;
        if (n < 0) return -2;
        if (n == 0) return 0; 
        long pow2 = pow(2, n-1);

        boolean free2 = free;
        if(bA[n-1][1] == 1){
            free2 = true;
        }

        if(free){
            ret = dfs(n-1, free) + Math.max(bA[n-1][0], (N-bA[n-1][0])) * pow2;
        } else if(bA[n-1][1] == 0){
            ret = dfs(n-1, free2) + bA[n-1][0] * pow2;
        } else {
            ret = Math.max(dfs(n-1, free2) + bA[n-1][0] * pow2,
                    dfs(n-1, free) + (N-bA[n-1][0]) * pow2);
        }
        return memo[n] = ret;
    }

public   static long pow(long x, long n) {
        long sum = 1;
        while (n > 0) {
            if ((n & 1) == 1) {  
                sum *= x;        
            }
            x *= x;              
            n >>= 1;
        }
        return sum;
    }

}
}



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

int main(void) {
    int A, B, C;
    
    cin >> A >> B >> C;
    
    if ((A == B && B == C && A == C) ||
        (A != B && B != C && A != C)) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<cstdio>

using namespace std;
/*
int find(int x, vector<int> &p) {
if (p[x] == x)return x;
return p[x] = find(p[x], p);
}

void uni(int x, int y, vector<int> &p) {
x = find(x, p);
y = find(y, p);
p[x] = y;
}

int same(int x, int y, vector<int> p) {
if (find(x, p) == find(y, p))return 1;
return 0;
}
*/

//long long a[1002];


int main()
{
	long long N, cnt = 0, tmp, ans = 0;
	vector<int> a(6), cn(4, 0);
	for (int i = 0; i < 3; i++) {
		cin >> a[i] >> a[i+3];
		cn[a[i]-1]++;
		cn[a[i + 3]-1]++;
	}

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

	if (cn[3] == 3) {
		cout << "NO";
	}
	else {
		cout << "YES";
	}

	char qq;
	cin >> qq;
	return 0;
}

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

string alphabet = "abcdefghijklmnopqrstuvwxyz";

int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans = 0;
	REP(i,n-1){
		int count = 0;
		map<char,int> mp1;
		map<char,int> mp2;
		for (int j = 0; j <= i; ++j) {
			mp1[s[j]]++;
		}
		for (int j = i+1; j < n; ++j) {
			mp2[s[j]]++;
		}
		rep(i,26){
			if(mp1[alphabet[i]] != 0 && mp2[alphabet[i]] != 0) count++;
		}
		ans = max(ans, count);
	}
	cout << ans << endl;
    return 0;
}



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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

int v[MAXN];

void solve(){
	int n;
	scanf("%d", &n);
	REP(i, 0, n){
		scanf("%d", &v[i]);
	}
	int cnt = 0;
	for(; ; cnt ^= 1){
		int cnt_odd = 0, ind_odd = 0;
		REP(i, 0, n){
			if (v[i] & 1){
				cnt_odd++;
				ind_odd = i;
			}
		}
		if (cnt_odd > 1 || v[ind_odd] == 1){
			break;
		}
		v[ind_odd]--;
		int g = 0;
		REP(i, 0, n){
			g = gcd(g, v[i]);
		}
		REP(i, 0, n){
			v[i] /= g;
		}
	}
	
	REP(i, 0, n){
		if (v[i] % 2 == 0){
			cnt ^= 1;
		}
	}
	
	if (cnt){
		printf("First\n");
	} else {
		printf("Second\n");
	}
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll d, g;
    cin >> d >> g;

    vl p(d), c(d);
    rep(i, d) {
        cin >> p[i] >> c[i];
    }

    ll ans = INF;
    rep(b, 1<<d) {  // bのiビット目が1のとき問題iを全て解く
        ll now = 0;  // いま解いた問題数
        ll point = 0;  // いまのポイント
        vl v(d);  // v[i] : bのiビット目
        rep(i, d) {
            if(b & 1<<i) {
                v[i] = 1;
            }
        }
        rep(i, d) {
            if(v[i]) {
                now += p[i];
                point += 100*(i+1)*p[i] + c[i];
            }
        }
        for(ll i = d-1; i >= 0; i--) {
            if(point >= g) {
                break;
            }
            if(v[i]) {
                continue;
            }
            if(point + 100*(i+1)*(p[i] - 1) < g) {
                point += 100*(i+1)*(p[i] - 1);
                now += p[i] - 1;
            }
            else {
                exrep(j, 0, p[i]-1) {
                    if(point >= g) {
                        break;
                    }
                    point += 100*(i+1);
                    now++;
                }
            }
        }
        if(point >= g) {
            chmin(ans, now);
        }
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	ll h,w; cin>>h>>w;
	ll h1,h2; h1=(h+1)/2; h2 = h/2;
	ll w1,w2; w1=(w+1)/2; w2 = w/2;
	ll ans;
	if(h==1||w==1) ans = 1;
	else ans = w1*h1 + w2*h2;
	cout << ans;

  return 0;
}


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

typedef long long ll;

int main(){
    int N,M;
    cin>>N>>M;
    vector<ll> X(M);
    vector<ll> dif(M);

    for(int i=0; i<M; i++) cin>>X[i];
    sort(X.begin(),X.end());

    dif[0] = 0;
    ll ans = X[M-1] -  X[0];

    for(int i=1; i<M; i++){
        dif[i] = (X[i]-X[i-1]);
    }
    sort(dif.begin(),dif.end(),greater<ll>());


    for(int i=0; i<min(N-1,M); i++){
        ans -= dif[i];
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1792
<?php

$n = (int)trim(fgets(STDIN));
$input = explode(" ", trim(fgets(STDIN)));
$t = (int)$input[0];
$a = (int)$input[1];

$args = [];
$count = 0;
while (true) {
	$input = trim(fgets(STDIN));
	$input = explode(" ", $input);
	foreach ($input as $value) {
		$args[] = (int)$value;
		++$count;
	}
	if ($count >= $n) {
		break;
	}
}

for ($i=0; $i < $n; $i++) { 
	$tmp = $args[$i];
	$diff = abs($a - ($t - $tmp * 0.006));
	if ($i === 0) {
		$result = $diff;
		$point = 0;
	}else{
		if ($diff < $result) {
			$result = $diff;
			$point = $i;
		}
	}
}
echo $point + 1;

Measured memory_bytes: 4732
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    int A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << min(A,B)+min(C,D) << "\n";
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
#define all(v) v.begin(),v.end()
#define endl "\n"
#define clr(n, r) memset(n,r,sizeof(n));

void fast() {
    cin.tie(0);
    cin.sync_with_stdio(0);
}

string b;
ll m, d, dp[10001][101][2], modu = 1e9 + 7;
ll ans(int i=0,int mod=0,bool high=0){
    if(i==b.size())return !mod;
    ll &res=dp[i][mod][high];
    if(~res)return res;
    res=0;
    for (int j = 0; j <=9 ; ++j) {
        if((!high&&j>b[i]-'0'))continue;
        res+=ans(i+1,(mod+j)%m,high||(j<b[i]-'0'))%modu;
        res%=modu;
    }
    return res;
}



int main() {
    fast();
    cin >> b>>m;
    clr(dp,-1);
    cout<<(ans()-1+modu)%modu;
}

Measured memory_bytes: 16896
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	int ans=0;
	cin >>n;
	vector<int> a(n),b(n);
	vector<int> suma(n+1,0),sumb(n+1,0);
	rep(i,n){
		cin>>a[i];
		if(i!=0){
			suma[i]+=suma[i-1];
		}
		suma[i]+=a[i];
		clog<<suma[i]<<" ";
	}
	clog<<endl;
	rep(i, n)
	{
		cin >> b[i];
	}
	clog<<endl;
	for(int i=n-1;i>=0;i--){
		sumb[i]+=sumb[i+1];
		sumb[i]+=b[i];
		clog<<sumb[i]<<" ";
	}
	rep(i,n){
		chmax(ans,suma[i]+sumb[i]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import math

N = int(input())

a = math.floor(N / 1.08)
b = a + 1

aa = math.floor(a * 1.08)
bb = math.floor(b * 1.08)

if(aa == N):
    print(a)
else:
    if(bb == N):
        print(b)
    else:
        print(":(")

Measured memory_bytes: 3060
import copy
N = int(input())
A = [0] * N
for i in range(N):
    A[i] = int(input())
amax = max(A)
B = copy.copy(A)
B.remove(amax)
nextmax = max(B)


for i in range(N):
    if A[i] == amax:
        print(nextmax)
    else:
        print(amax)

Measured memory_bytes: 14524
/*
      author : nishi5451
      created: 11.08.2020 22:04:07
*/

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


int main(){
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    if(s[0]==s[1] && s[2]==s[3] && s[2]!=s[1]) 
        cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll INF = 1LL << 62;
const int inf = 1 << 30;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int r, g, b; cin >> r >> g >> b;
    int x = 100 * r + 10 * g + b;

    string res = "NO";
    if(x % 4 == 0){
        res = "YES";
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
import io.StdIn.readLine

object Main extends App {
  val in = readLine.split(" ").map(_.toInt).toList

  def loop(list: List[Int]): String = list match {
    case _ :: Nil => "Yes"
    case head :: tail if head < tail.head => loop(tail)
    case _ => "No"
  }

  val result = loop(in)
  println(result)
}



Measured memory_bytes: 43928
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f(i,a,b) for(ll i=(a);i<(b);i++)
#define frr(i,a,b) for(ll i=(a-1);i>=(b);i--)
#define vi vector<int>
#define de deque<int>
#define del deque<ll>
#define vl vector<ll>
#define pb push_back
#define ppb pop_back()
#define pf push_front
#define ppf pop_front()
#define mpp map<ll,ll>
#define rev(a) reverse(a.begin(),a.end())
#define srt(a) sort(a.begin(),a.end())
#define ln(a) a.length()
#define sz(a) a.size()
#define endl "\n"
int M=1000000007;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

int n;cin>>n;
ll a[n];
f(i,0,n)cin>>a[i];
ll dp[n+1][n+1];
memset(dp,0,sizeof dp);
frr(i,n,0)
{
    f(j,i,n)
    {
        if(i==j){if(n%2==1)dp[i][j]=a[i];else{dp[i][j]=-a[i];}}
        else if((i+j+1)%2==n%2)
        {
            dp[i][j]=max(dp[i+1][j]+a[i],dp[i][j-1]+a[j]);
        }
        else
        {
          dp[i][j]=min(dp[i+1][j]-a[i],dp[i][j-1]-a[j]);
        }
    }

}
cout<<dp[0][n-1]<<endl;

}



Measured memory_bytes: 70656
#include<stdio.h>

int main(void)

{


   int a_cm=0,b_cm=0,mennseki,x;

   mennseki=a_cm*b_cm;


   scanf("%d %d",&a_cm,&b_cm);

   mennseki=a_cm*b_cm;
	
   printf("%d ",mennseki);


   x=a_cm*2+b_cm*2;


   printf("%d\n",x);

return 0;


}

Measured memory_bytes: 596
a, b, k = map(int, input().split())
ans = []
if (b-a+1)/2 > k:
    for i in range(k):
        ans.append(a+i)
        ans.append(b-k+1+i)
    [print(i) for i in sorted(set(ans))]
else:
    [print(i) for i in range(a, b+1)]


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, ll>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

vector<bool> seen(100010);
vector<ll> cost(100010);
void dfs(const Graph &G, ll v, ll c)
{
    seen[v] = true;

    for (auto &&next_v : G[v])
    {
        if (seen[next_v.first])
            continue;
        cost[next_v.first] = c + next_v.second;
        dfs(G, next_v.first, cost[next_v.first]);
    }
}
int main()
{
    long long N;
    scanf("%lld", &N);
    Graph G(N);
    for (int i = 0; i < N - 1; i++)
    {
        ll a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        G[a].push_back(make_pair(b, c));
        G[b].push_back(make_pair(a, c));
    }

    long long Q;
    scanf("%lld", &Q);
    long long K;
    scanf("%lld", &K);
    K--;
    dfs(G, K, 0);
    std::vector<long long> x(Q);
    std::vector<long long> y(Q);
    for (int i = 0; i < Q; i++)
    {
        ll x, y;
        cin >> x >> y;
        x--;
        y--;
        cout << cost[x] + cost[y] << endl;
    }
    return 0;
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n; 
struct SG{
	int cnt,L[400004],R[400004],dat[400004];
	int init(int l,int r){
		int id=++cnt;
		if(l!=r)L[id]=init(l,(l+r)/2),R[id]=init((l+r)/2+1,r);
		dat[id]=n-1;
		return id;
	}
	void push(int id,int x){
		if(dat[id]>x)dat[id]=x;
	}
	int F(int l,int r,int id,int pos){
		if(l==r)return dat[id];
		push(L[id],dat[id]),push(R[id],dat[id]);
		if((l+r)/2>=pos)return F(l,(l+r)/2,L[id],pos);
		return F((l+r)/2+1,r,R[id],pos);
	}
	void upd(int l,int r,int id,int a,int b,int x){
		if(r<a||b<l)return;
		if(a<=l&&r<=b){
			push(id,x);
			return;
		}
		push(L[id],dat[id]),push(R[id],dat[id]);
		upd(l,(l+r)/2,L[id],a,b,x);
		upd((l+r)/2+1,r,R[id],a,b,x);
	}
}T[2];
int Q;
int main(){
	cin>>n>>Q;
	ll cur=1ll*(n-2)*(n-2);
	T[0].cnt=0,T[1].cnt=0;
	T[0].init(1,n-2),T[1].init(1,n-2);
	while(Q--){
		int x,y;cin>>x>>y;
		int op=0;
		if(x==2)x=1,op=1;
		y--;
		int ret=T[op].F(1,n-2,1,y);
		T[op].upd(1,n-2,1,y,y,1);
		cur-=ret-1;
		T[op^1].upd(1,n-2,1,1,ret-1,y);
	}
	cout<<cur;
}

Measured memory_bytes: 13004