akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a:A) cin >> a;}


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

i64 X; cin >> X;

map<i64, int> gojo;
rep(i, -200, 200) gojo[pow(i, 5)] = i;

for(pair<i64, int> B5: gojo){
    if (gojo.count(X + B5.first)) {
        cout << gojo[X + B5.first] << " " << B5.second << "\n"; 
        return 0;
    }
}

return 0;
}
// コンテスト前はtemplate振り返り。
// 書いて考える．場合分け．情報整理．
// 問題文から考える。自分ができることから考える。
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索。逆から考える。
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 4084
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int gi(){
	int x=0,w=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')w=0,ch=getchar();
	while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return w?x:-x;
}
const int N=1e5+5;
const int mod=1e9+7;
int n,t[26],ans=1;char s[N];
int main(){
	scanf("%d",&n);scanf("%s",s+1);
	for(int i=1;i<=n;++i)++t[s[i]-'a'];
	for(int i=0;i<26;++i)ans=1ll*ans*(t[i]+1)%mod;
	printf("%d\n",(ans+mod-1)%mod);return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n)   for(int i=0;i<(n);++i)
#define ALL(v)     (v).begin(),(v).end()
#define debug(x)   cerr<<#x<<": "<<(x)<<endl
using namespace std;
using llong = long long;
using vi    = vector<int>;
using vvi   = vector<vi >;
using vvvi  = vector<vvi >;
using pii   = pair<int,int>;
constexpr int    INF=1e9;
constexpr double EPS=1e-9;
constexpr int    MOD=1e9+7;
template<class Type>
void line(const Type &a){int cnt=0;for(const auto &elem:a){cerr<<(cnt++?' ':'>');cerr<<elem;}cerr<<endl;}

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

int main(){
	llong a[2],b[2];
	REP(i,2) cin>>a[i];
	REP(i,2) cin>>b[i];
	
	llong tmp[4];
	REP(i,2)REP(j,2) tmp[2*i+j]=a[i]*b[j];
	
	llong ans=tmp[0];
	REP(i,4) chmax(ans,tmp[i]);
	
	cout<<ans<<endl;
}

Measured memory_bytes: 3632
# -*- coding: utf-8 -*-

def main():

	a,b,c = map(int,raw_input().split())
	for i in xrange(2):
		if a > b:
			a,b = sort(a,b)
		if b > c:
			b,c = sort(b,c)
	print('%d %d %d' % (a,b,c))

def sort(x,y):

	temp = x
	x = y
	y = temp
	return x,y

if __name__ == "__main__":

	main()


Measured memory_bytes: 6408
#include<bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
// greater<int>()
typedef long long ll;
ll GCD(ll x, ll y) { return y ? GCD(y, x%y) : x; }
ll LCM(ll x, ll y) { return x * y / GCD(x, y); }

using namespace std;


int main() {
	int n;
	cin >> n;
	vector<int> vec(n);

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

	for (int i = n - 1; i >= 0; i = i - 2)
	{
		cout << vec[i] << " ";
	}

	int i = 0;
	if (n % 2 == 1) {
		i = 1;
	}
	
	for (i ; i < n; i  = i+ 2)
	{
		cout << vec[i] << " ";

	}








}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define maxn 200005
using namespace std;
struct ball {
	int x,y;
}arr[maxn];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	for(int i=1;i<=n;i++) {
		cin >> arr[i].x >> arr[i].y;
		if(arr[i].x > arr[i].y)
			swap(arr[i].x,arr[i].y);
	}
	sort(arr+1,arr+1+n,[=](ball a,ball b)->bool
		{return a.x < b.x;});
	multiset<int> R,B;
	for(int i=1;i<=n;i++) {
		R.insert(arr[i].x);
		B.insert(arr[i].y);
	}
	ll ans = (ll)(*R.rbegin() - *R.begin()) * (*B.rbegin() - *B.begin());
	for(int i=1;i<=n;i++) {
		R.erase(R.lower_bound(arr[i].x));
		B.insert(arr[i].x);
		B.erase(B.lower_bound(arr[i].y));
		R.insert(arr[i].y);
		ans = min(ans,(ll)(*R.rbegin() - *R.begin()) * (*B.rbegin() - *B.begin()));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 22656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,h,w;cin >> n >> h >> w;
	cout << (n-h+1)*(n-w+1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pob pop_back
#define MP make_pair
#define VI vector<int>
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.F<<","<<_p.S<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}

template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5;
const ll MOD=1000000007;
const ll INF=(ll)1e18;

string a,b,c;

int main(){
  IOS();
  cin>>a>>b>>c;
  cout<<a[0]<<b[1]<<c[2]<<endl;
}


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

int arr[N];
int a[55];
int n;
int j = 0;

int main()
{
    cin >> n;
    for(int i = 0; i < N; i++)
    {
        arr[i] = 1;
    }
    for(int i = 2; i < sqrt(N); i++)
    {
        if(arr[i]){
            for(int j = 0; i * (j + 2) < N; j++){
                arr[i * (j + 2)] = 0;
            }
        }
    }
    
    for(int i = 2; i < N; i++)
    {
        if(arr[i] && i % 5 == 1 && j != 55)
        {
            a[j] = i;
            j = j + 1;
        }
    }
    
    for(int i = 0; i < n-1; i++)
    {
        cout << a[i] << " ";
    }
    
    cout << a[n-1];
    
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<iterator>
#include<algorithm>
int main()
{
  using namespace std;
  int n;
  cin>>n;
  if(n&1)
  cout<<((n+1)/2.0/n)<<endl;
  else
  cout<<(1/2.0)<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,cnt=0,m,ans=1,a[55];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>m>>n;
	for(int i=2; i<=sqrt(n); i++) {
		if(n%i==0) {
			a[cnt++]=i;
			n=n/i;
			i--;
		}
	}
	if(n!=1) {
		a[cnt++]=n;
	}
	a[cnt++]=0;
	ll pos=a[0],sum=0;
	for(int i=0; i<cnt; i++) {
		if(a[i]==pos) {
			sum++;
		} else {
			if(sum>=m) {
				sum/=m;
				ans*=pow(pos,sum);
			}
			pos=a[i];
			sum=1;
		}
	}
	cout<<ans<<endl;
}

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

using namespace std;

using ll = long long;

constexpr ll inf = 1e18 + 17;

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

  int n;
  cin >> n;

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

  vector<ll> pre(1 << n);
  for (int i = 1; i < (1 << n); ++i) {
    int j = i;
    ll cur = 0;
    while (j) {
      int b = log2(j & -j);
      for (int k = 0; k < b; ++k) {
        if (i & (1 << k)) {
          cur += a[k][b];
        }
      }
      j &= j - 1;
    }
    pre[i] = cur;
  }

  vector<ll> dp(1 << n, -inf);
  dp[0] = 0;
  for (int i = 0; i < (1 << n); ++i) {
    int mask = ~i & ((1 << n) - 1);
    for (int k = mask;; k = (k - 1) & mask) {
      dp[i | k] = max(dp[i | k], dp[i] + pre[k]);
      if (!k) {
        break;
      }
    }
  }

  cout << dp[(1 << n) - 1] << '\n';

  return 0;
}


Measured memory_bytes: 1280
sx,sy,tx,ty=map(int,input().split())
dx=tx-sx
dy=ty-sy
ans=["DU"[dy>0]*dy+"LR"[dx>0]*dx,"DU"[dy<0]*dy+"LR"[dx<0]*dx]
ans.append(ans[1][-1]+ans[0][0]+ans[0]+ans[0][-1]+ans[1][0])
ans+=[{"L":"R","R":"L","U":"D","D":"U"}[c]for c in ans[2]]
print("".join(ans))

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


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

using namespace std;

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


const long long MAX_N = 1 << 17;

long long dat[2 * MAX_N - 1];

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

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

//F
int main(void) {
	string s, t;
	cin >> s >> t;
	if (s.size() > t.size()) swap(s, t);
	vector<vector<ll>> dp = vector<vector<ll>>(s.size() + 1, vector<ll>(t.size() + 1,0));
	rep(i, 0, s.size()) {
		rep(j, 0, t.size()) {
			if (s[i] == t[j]) {
				dp[i + 1][j + 1] = dp[i][j] + 1;
			}
			else {
				dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
			}
		}

	}
	ll i = s.size() - 1, j = t.size() - 1;
	string str;
	while (i >= 0 && j >= 0) {
		if (s[i] == t[j]) {
			str += s[i];
			i--;
			j--;
		}
		else {
			if (dp[i][j + 1] < dp[i + 1][j])j--;
			else i--;
		}
	}
	reverse(str.begin(), str.end());
	
	cout  << str << endl;
}

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

int card[255][14] = {{0}};
    
int main (void){
    int n;
    cin >> n;
    for (int i =0; i < n; i++){
        char c;
        int num;
        cin >> c >> num;
        card[(int)c][num] = 1;
    }
    
    for(int i = 1; i <= 13; i++){
        if(card[(int)'S'][i] == 0){
            cout << "S " << i << endl;
        }
    }
    
    for(int i = 1; i <= 13; i++){
        if(card[(int)'H'][i] == 0){
            cout << "H " << i << endl;
        }
    }
    
    for(int i = 1; i <= 13; i++){
        if(card[(int)'C'][i] == 0){
            cout << "C " << i << endl;
        }
    }
    
    for(int i = 1; i <= 13; i++){
        if(card[(int)'D'][i] == 0){
            cout << "D " << i << endl;
        }
    }
}
//ITP1_6_B*


Measured memory_bytes: 3080
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 H, W, K;
  std::cin >> H >> W >> K;
  std::vector<std::string> s;
  tools::read(s, H);

  std::vector<std::vector<i64>> a(H, std::vector<i64>(W, 0));
  i64 next = 1;
  for (i64 i = 0; i < H; ++i) {
    for (i64 j = 0; j < W; ++j) {
      if (s[i][j] == '#') {
        i64 upmost;
        for (upmost = i; upmost >= 0 && a[upmost][j] == 0; --upmost);
        ++upmost;
        i64 leftmost;
        for (leftmost = j; leftmost >= 0 && a[i][leftmost] == 0; --leftmost);
        ++leftmost;
        i64 rightmost;
        for (rightmost = j + 1; rightmost < W && s[i][rightmost] == '.'; ++rightmost);
        --rightmost;
        for (i64 k = upmost; k <= i; ++k) {
          for (i64 l = leftmost; l <= rightmost; ++l) {
            a[k][l] = next;
          }
        }
        ++next;
      }
    }
  }

  for (i64 j = 0; j < W; ++j) {
    i64 upmost;
    for (upmost = H - 1; a[upmost][j] == 0; --upmost);
    ++upmost;

    for (i64 i = upmost; i < H; ++i) {
      a[i][j] = a[upmost - 1][j];
    }
  }

  for (i64 i = 0; i < H; ++i) {
    for (i64 j = 0; j < W; ++j) {
      if (j > 0) std::cout << ' ';
      std::cout << a[i][j];
    }
    std::cout << std::endl;
  }
  return 0;
}

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

int main() {
ll n;
cin >> n;
ll a[n];
ll cnt = 1;
for (ll i = 0; i < n; i++) cin >> a[i];
ll ans = 0;
bool flag = false;
for (ll i = 0; i < n; i++) {
    if (a[i] == 1) flag = true;
}
if(!flag){
    cout << "-1" << endl;
    return 0;
}
for (ll i = 0; i < n; i++) {
        if (a[i] == cnt) cnt++;
        else
            ans++;
}
cout << ans << endl;
}


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

using namespace std;

int dp[100100][3], a[100100][3];

int main(){
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 3; j++) cin >> a[i][j];
    }
    for(int j = 0; j < 3; j++) dp[0][j] = a[0][j];
    for(int i = 1; i < n; i++){
        for(int j = 0; j < 3; j++){
            int mx = 0;
            for(int k = 0; k < 3; k++){
                if(j != k) mx = max(dp[i - 1][k], mx);
            }
            dp[i][j] = mx + a[i][j];
        }
    }
    int ans = max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]});
    cout << ans << '\n';
}

Measured memory_bytes: 2560
// AOJ 0572 Card Game is Fun
// 2017.10.29 bal4u
// 2018.2.23

#include <stdio.h>

int a[5003], b[5003];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int main()
{
	int la, lb, i, j, ans;

	la = in(), lb = in();
	for (i = 0; i < la; i++) a[i] = in();
	for (i = 0; i < lb; i++) b[i] = in();

	ans = 0;
	for (i = 0; i < lb; i++) {
		int t = i, k = 0;
		if (lb - i < ans) break;
		for (j = 0; j < la && t < lb; j++) if (a[j] == b[t]) t++, k++;
		if (k > ans) ans = k;
	}
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 2100
#!/usr/bin/env python

if __name__ == '__main__':
    n, m = map(int, raw_input().split())

    A = [map(int, raw_input().split()) for _ in range(n)]
    B = [[int(raw_input())] for _ in range(m)]

    for i in range(n):
        print sum([A[i][j]*B[j][0] for j in range(m)])


Measured memory_bytes: 4824
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

ll mod=1e9+7;
vector<ll>adj[100005];
ll dist[100005];
ll parent[100005];
ll n,m;
            
            void sssp(ll source)
            {
                memset(dist,-1,sizeof(dist));
		    	memset(parent,-1,sizeof(parent));
                queue<ll>q;
                q.push(source);
                dist[source]=0;
                while(!q.empty())
                {
                    ll cn=q.front();
                    q.pop();

                    for(auto it:adj[cn])
                    {
                        if(dist[it]==-1)
                        {
			    			parent[it]=cn;
                            dist[it]=dist[cn]+1;
                            q.push(it);
                        }
                    }
                }
            }
        


 
int main() {
				fast
				// #ifndef ONLINE_JUDGE
				// freopen("input.txt","r",stdin);
				// freopen("output.txt","w",stdout);
				// #endif

                
                cin>>n>>m;
                for(ll i=0;i<m;i++)
                {
                ll a,b;
                cin>>a>>b;
                adj[a].pb(b);
                adj[b].pb(a);
                }
                sssp(1);
				bool flag=1;
				for(ll i=2;i<=n;i++)
				{
					if(dist[i]<0)
					flag=0;

				}
				if(flag)
				{
					cout<<"Yes"<<endl;
					for(ll i=2;i<=n;i++)
					cout<<parent[i]<<endl;
				}
				else
				{
					cout<<"No"<<endl;
				}
				
               

                return 0;
            }

Measured memory_bytes: 13744
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
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 main() {
    string s; cin >> s;

    while(!s.empty()){
        s.pop_back();
        if(s.size() % 2) continue;
        string a = s.substr(0, s.size()/2);
        string b = s.substr(s.size()/2, s.size()/2);
        if(a == b) break;
    }
    cout << s.size() << ln;
}

    

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define all(x) x.begin(),x.end()
#define pb push_back
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define sll set<ll>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define endl "\n"
const ll maxn = 2e5+2;

int main()
{
    fastio; //remove for interactive
    ll i, j, k, n, m;
    string s,t;
    
    cin>>s>>t;
    t.pop_back();
    if(s==t)
        cout<<"Yes"<<endl;
    else
    {
        cout<<"No"<<endl;
    }
    
        
    return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int n,m,c,i,j,a[20],b[20],x,cnt;
	cnt=0;
	cin>>n>>m>>c;
	for(i=0;i<m;i++) {
		cin>>b[i];
	}
	for(i=0;i<n;i++){
		x=0;
		for(j=0;j<m;j++){
			cin>>a[j];
			x=x+a[j]*b[j];
		}
		x=x+c;
		if(x>0){
			cnt=cnt+1;
		}
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#2019/10/25
A,B,C,X =[int(s) for s in open(0)]
# print(A,B,C,X)
cnt=0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if 500*i+100*j+50*k == X:
                cnt+=1
print(cnt)

Measured memory_bytes: 2940
fun main() {
    val x = nextLong()
    println(res(x))
}

fun res(n: Long): String {
    val resStr = (n*n*n*1000000000/27L).toString()
    return if (n == 1L) {
        "0.0$resStr"
    } else if (n == 2L) {
        "0.$resStr"
    } else {
        resStr.substring(0, resStr.length - 9) + "." + resStr.substring(resStr.length - 9, resStr.length)
    }
}


fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(' ')
fun nextIntList() = nextList().map { it.toInt() }
fun nextLongList() = nextList().map { it.toLong() }
fun nextDoubleList() = nextList().map { it.toDouble() }


Measured memory_bytes: 34648
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define Rep1(i,k,n) for(int i=k ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
//#define int ll
typedef long long ll;

const int md = 1000000007;
const int INF = 1<<30;
using namespace std;


int main(){
    int n,m; cin >> n >> m;
    vector<vector<pair<int,int>>> edge;
    vector<bool> visited(n+1,false);
    //vector<bool> wb(n+1, false);
    
    int ans = 0;
 
    rep(i,n+1) edge.emplace_back();
    rep(i,m){
        int a,b,c; cin >> a >> b >> c;
        edge[a].emplace_back(b,c);
        edge[b].emplace_back(a,c);
    }

    //int path = 0;
    
    rep1(i,n){
        if(visited[i]) continue;
        ans++;
        queue<int> bfs;
        bfs.push(i);

        while(!bfs.empty()){
            int tmp = bfs.front();
            visited[tmp] = true;
            bfs.pop();
            
            rep(i,edge[tmp].size()){
                int next = edge[tmp][i].first;
                if(!visited[next]) {
                    bfs.push(next);
                    

                }
                //path++;
            }
        }
        

        //allvisit = true;
        //rep1(i,n) if(!visited[i]) allvisit = false;
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 6896
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	int n,l=0,r=0,i;
	string s;
	cin >> n;
	cin >> s;
	for(i=0; i<n; ++i){
		if(s[i]=='('){
			++l;
		}else if(l){
			--l;
		}else{
			++r;
		}
	}
	for(i=0; i<r; ++i){
		cout << "(";
	}
	cout << s;
	for(i=0; i<l; ++i){
		cout << ")";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())

A = list(map(int, input().split())) + [0]

total = 1000
stock = 0

if A[0] < A[1]:
    stock = total // A[0]
    total -= stock * A[0]

for i in range(1, N):
    if A[i] > A[i+1] and stock != 0:
        total += stock*A[i]
        stock = 0
    if A[i] < A[i+1] and stock == 0:
        stock = total//A[i]
        total -= stock*A[i]

print(total)




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

int main()
{
	int n;
	cin>>n;
	int arr[n][3];
	for(int i=0;i<n;i++)
	cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
	
	int dp[n][3];
	dp[0][0]=arr[0][0];
	dp[0][1]=arr[0][1];
	dp[0][2]=arr[0][2];
	
	for(int i=1;i<n;i++)
	{
		dp[i][0]=arr[i][0]+max(dp[i-1][1],dp[i-1][2]);
		dp[i][1]=arr[i][1]+max(dp[i-1][0],dp[i-1][2]);
		dp[i][2]=arr[i][2]+max(dp[i-1][0],dp[i-1][1]);
	}
	int ans = max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
	cout<<ans<<"\n";
	
}
	
	
				


Measured memory_bytes: 5936
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    int n,l;
    cin >> n >>l;
    string s[n];
    int i;
    for(i=0;i<n;i++){
      cin >> s[i];
    }
    sort(s,s+n);
    for(i=0;i<n;i++){
      cout << s[i];
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            long b = 1;
            for(int i = 1;i<=a;i++)
            {
                b = b * i;
                b = b % (1000000000 + 7);
            }


            Console.Write(b);
        }
    }
}


Measured memory_bytes: 11092
s=input()
ans0=0
ans1=0

for i in range(len(s)):
    if i%2==0:
        if s[i]=="0":
            ans0+=1
    else:
        if s[i]=="1":
            ans0+=1

for i in range(len(s)):
    if i%2==0:
        if s[i]=="1":
            ans1+=1
    else:
        if s[i]=="0":
            ans1+=1
#print(ans0)
#print(ans1)
print(min(ans0,ans1))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}

void solve(long long N, long long M, std::vector<long long> A, std::vector<long long> B){
  priority_queue<ll> q;
  q.push(2);
  q.pop();
  vector<pll> AB;
  REP(A.size()){
    AB.push_back(pll(A[i],B[i]));
  }
  sort(AB.begin(),AB.end());
  ll idx=0;
  ll ans=0;
  REP(M){
    dump(i);
    while(idx<AB.size()&&AB[idx].first<=i+1){
      dump(AB[idx]);
      ll tmp=AB[idx].second;
      dump(tmp);
      q.push(tmp);
      ++idx;
    }
    if(!q.empty()){
      ans+=q.top();
      q.pop();
    }
  }
  cout<<ans<<endl;
}

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


Measured memory_bytes: 5232
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for (int i=0,_n=(int)(n); i < _n; i++)
template<class T> bool chmax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<class T> bool chmin(T &a, T b) { return a > b ? (a = b, true) : false; }
 
typedef long long ll;

ll f(ll I, ll J, ll L) {
  ll ans = 0;
  ans += 4 * (I / 2);
  ans += 4 * (J / 2);
  ans += 4 * (L / 2);
  return ans;
}

int main() {
  ll  I, O, T, J, L, S, Z;
  cin >> I >> O>> T>> J>> L>> S>> Z;
  ll ans = 0;
  ans += 2 * (O);

  ll p1 = f(I, J, L);
  ll p2 = 0;
  if (I >= 1 && J >= 1 && L >= 1) {
    p2 += 6 + f(I - 1, J - 1, L - 1);
  }
  ans += max(p1, p2);
  cout << (ans/2) << endl;
  return 0;
}

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

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

    if (n == 1){
        cout << "Yes" << endl;
        return 0;
    }
    // 右から考える
    // 左と同じ、あるいは大きければよい

    // vector <int>::iterator testIter = h.begin();
    // cout << *(testIter + 1) << endl;

    for (vector <int>::reverse_iterator iter = h.rbegin(); iter != h.rend(); iter++){
        if (*(iter + 1) - *iter > 1 ){
            // cout << *(iter + 1) << endl;
            // cout << *iter << endl;
            cout << "No" << endl;
            // cout << "Case1" << endl;
            return 0;
        }
        else if (*(iter + 1) - *iter == 1){
            // cout << *(iter + 1) << endl;
            --*(iter + 1);
            // cout << *(iter + 1) << endl;
            // cout << "Case2" << endl;
        }
        // else if (*(iter - 1) < *iter){
        //     cout << "No" << endl;
        //     cout << "Case3" << endl;
        //     return 0;
        // }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)

using namespace std;
typedef long long int ll;
typedef pair<int,int> PI;

const int MOD = 1000000007;
string s;
ll dp1[100002], dp2[100002];
int main(void){
    cin >> s;
    int N = s.length();
    dp1[0] = 2;
    dp2[0] = 1;

    for(int i=1;i<N;i++){
        if(s[i] == '1'){
                dp1[i] = ((dp1[i-1]%MOD)*2)%MOD;
                dp2[i] = ((dp1[i-1]%MOD) + ((dp2[i-1]%MOD)*3)%MOD)%MOD;
        }else{
                dp1[i] = dp1[i-1];
                dp2[i] = ((dp2[i-1]%MOD)*3)%MOD;
        }
    }

    cout << (dp1[N-1] + dp2[N-1]) % MOD << endl;
    return 0;
}



Measured memory_bytes: 2048
from collections import defaultdict
from itertools import chain


def gcd(a, b):
    # 最大公約数
    while b:
        a, b = b, a % b
    return a


def fast_prime_set(n):
    # nまでの素数リスト高速版 setで返す
    # chainの読み込みが必要！
    if n < 4:
        return ({}, {}, {2}, {2, 3})[n]
    n_sqrt = int(n ** 0.5) + 1
    primes = {2, 3} | set(chain(range(5, n + 1, 6), range(7, n + 1, 6)))
    for i in range(5, n_sqrt, 2):
        if i in primes:
            primes.difference_update(range(i * i, n, i * 2))
    return primes


def prime_factorization(x):
    # 素因数分解
    # 事前に素数のセットが必要
    primes = fast_prime_set(10 ** 6)

    fact = defaultdict(int)
    for prime in primes:
        while x % prime == 0:
            fact[prime] += 1
            x //= prime
        if x == 1:
            break
        if x in primes:
            fact[x] += 1
            break
    if x!= 1:
        fact[x] = 1
    return fact


if __name__ == '__main__':
    a, b = map(int, input().split())
    gcd_a_b = gcd(a, b)
    prime_fact = prime_factorization(gcd_a_b)
    print(1 + len(prime_fact))

Measured memory_bytes: 38500
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Scan()
	str := sc.Text()
	n, _ := strconv.Atoi(str)

	sum := 0
	for _, c := range str {
		n, _ := strconv.Atoi(string(c))
		sum += n
	}

	if n%sum == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
N = int(input())
a = [list(map(int, input().split())) for i in range(N)]
b = [list(map(int, input().split())) for i in range(N)]
a = sorted(a, key=lambda x: x[1])[::-1]
b = sorted(b)
ans = 0
for n in range(N):
    for i in range(len(b)):
        for j in range(len(a)):
            if b[i][0] > a[j][0]:
                if b[i][1] > a[j][1]:
                    ans+=1
                    del a[j]
                    del b[i]
                    break
        else:
            continue
        break
print(ans)

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> t(n);
  int i;
  for (i = 0; i < n; i++) {
    cin >> t[i];
  }
  vector<int> diff(n - 1);
  for (i = 1; i < n; i++) {
    diff[i - 1] = t[i] - t[i - 1] - 1;
  }
  sort(diff.begin(), diff.end());
  int reslut = 0;
  for (i = 0; i < n - k; i++) {
    reslut += diff[i];
  }
  reslut += n;
  cout << reslut << endl;
  return 0;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define vl          vector<ll>
#define vi          vector<int>
#define pi          pair<int,int>
#define pl          pair<ll,ll>
#define all(a)      a.begin(),a.end()
#define mem(a,x)    memset(a,x,sizeof(a))
#define pb          push_back
#define mp          make_pair
#define F           first
#define S           second
#define endl 		"\n"
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define fast_io     std::ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define trace(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1) {std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " : " << arg1;
	ZZ(comma, args...);
}

ll n, k;
bool check(ll d, vl &a) {
	ll cnt = 0;
	rep(i, 0, n) {
		cnt += (a[i] / d);
		if (a[i] % d == 0) {
			cnt--;
		}
		if (cnt > k)return false;
	}
	if (cnt > k)return false;
	else return true;
}
void solve() {
	cin >> n >> k;
	vl a(n);
	ll ma = 0;
	rep(i, 0, n) {
		cin >> a[i];
		ma = max(ma, a[i]);
	}
	ll lo = 1, hi = ma, ans = hi;
	while (lo < hi) {
		ll mid = (lo + hi) / 2;
		if (check(mid, a)) {
			hi = mid;
			ans = min(ans, mid);
		}
		else {
			lo = mid + 1;
		}
		// trace(lo, hi, mid)
	}
	cout << ans;
}
int main() {
	fast_io;
	int t = 1;
	// cin>>t;
	while (t--) {
		solve();
	}
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 4720
<?php
   fscanf(STDIN, "%d", $n);
     $ans=1;
   $arr = array_map('intval', explode(' ', trim(fgets(STDIN))));
   if (in_array('0', $arr)){
     $ans= 0;
   }else{
     for($i=0;$i<$n;++$i){
      $ans=bcmul($ans,$arr[$i]);
      if($ans>1000000000000000000){
        $ans= -1;
        break;
       }
     }
    }
   echo $ans;
?>

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

int main(){
 int a,b;
  cin>>a;
  vector<int> n(1000000),p(1000000);
 
  for(int i=0;i<1000000;i++){
 n[i]=0;
    }
  n[0]=a;
  p[a]=1;
  
  for(int i=0;i<1000000;i++){
    //cout<<n[i]<<endl;
if(n[i]%2==0){
  n[i+1]=n[i]/2;
}
    else{
    n[i+1]=3*n[i]+1;
    }
   
   if(p[n[i+1]]==1){
     b=i+2;
     break;
   }
    else{
      p[n[i+1]]++;
     
    }
  }
  cout<<b<<endl;

}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define ALL(a) (a).begin(),(a).end()
#define EACH(e,v) for(auto& e:v)
#define SORT(v) sort(ALL(v))
#define PERM(v) SORT(v);for(bool c##p=1;c##p;c##p=next_permutation(ALL(v)))
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <class T> void chmax(T & a, T const & b) { if (b > a) a = b; }
template <typename T>
string to_string(const T &n){ostringstream stm;stm << n;return stm.str();}
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = 1000'000'007;
 

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int se[112345];
signed main(){
    int n;
    cin>>n;
    vector<ll> avec;
    rep(i,n+1){
        ll a;cin>>a;avec.push_back(a);
    }
    COMinit();

    int idx=0;
    int idxb=0;
    rep(i,n+1){
        se[avec[i]]++;
        if(se[avec[i]]==2)idx=i;
    }

    rep(i,n+1){
        if(avec[idx]==avec[i]){
            idxb=i;
            break;
        }
    }
    swap(idx,idxb);
    int b=idxb-idx-1;int c=n-idxb;
    ll ans=0LL;
    rep(i,n+1){
        int k=i+1;
        if(i==0)cout<<n<<endl;
        else {
            ll ret=0;
            ret+=COM(n-1,k)%mod;
            ret+=COM(idx+c,k-1)%mod;
            ret+=(COM(idx+b+c,k-1)-COM(idx+c,k-1))*2%mod;
            ret+=COM(n-1,k-2)%mod;
            cout<<(ret%mod+mod)%mod<<endl;
        }
    }
    
 
}

Measured memory_bytes: 14452
#include<iostream>
#include<string>
#include<stdio.h>
using namespace std;
int main() {
	string S;
	cin >> S;
	if (S[0] == S[1] & S[2] == S[3] &S[0]!=S[2]) {
		cout << "Yes" << endl;
	}
	else if (S[0] == S[2] & S[1] == S[3] & S[0] != S[1]) {
		cout << "Yes" << endl;
	}
	else if (S[0] == S[3] & S[1] == S[2] & S[0] != S[1]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

int main(){
    string s;cin >> s;
    int n;cin >> n;
    vector<string> v;
    for(int i=1;i<=min(5,(int)s.size());i++){
        for(int j=0;j<s.size()-i+1;j++){
            string tmp = s.substr(j,i);
            v.push_back(tmp);
        }
    }
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
    cout << v[n-1] << endl;
    return 0; 
}

Measured memory_bytes: 1660
n, k = map(int, input().split())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7

mia = sorted([i for i in a if i < 0], reverse=True)
pla = sorted([i for i in a if i >= 0])
ans, num = 1, []

if len(pla) == 0 and k % 2 == 1:
    for i in mia[:k]:
        ans = ans * i % mod
    print(ans)
    exit()

for _ in range(k):
    if len(mia) > 0 and len(pla) > 0:
        if abs(mia[-1]) <= pla[-1]:
            tmp = pla.pop()
        elif abs(mia[-1]) > pla[-1]:
            tmp = mia.pop()
    elif len(mia) == 0:
        tmp = pla.pop()
    elif len(pla) == 0:
        tmp = mia.pop()
    num.append(tmp)

cnt = sum(i < 0 for i in num)
for i in num:
    ans = ans * i % mod

if cnt % 2 == 1:
    p, q, r, s = 1, 0, -1, 0
    if len(mia) > 0 and cnt != k:
        p,q = min(i for i in num if i >= 0), mia[-1]
    if len(pla) > 0:
        for i in num[::-1]:
            if i < 0:
                r, s = i, pla[-1]
                break
    if len(mia) > 0 or (len(pla) > 0 and cnt != k):
        if q * r >= p * s:
            ans *= q * pow(p, mod - 2, mod)
        if q * r < p * s:
            ans *= s * pow(r, mod - 2, mod)
    ans %= mod
print(ans)


Measured memory_bytes: 33204
#include <bits/stdc++.h>
#define forn(x, n)              for (int x = 0; x < n; x++)
#define forr(x, n)              for (int x = n; x >= 0; x--)
#define fore(x, a, b, c)        for (int x = a; x <= b; x += c)
#define forre(x, a, b, c)       for (int x = a; x >= b; x -= c)
#define clr                     cin.ignore(numeric_limits<streamsize>::max(), '\n')
#define lb(container, val)      lower_bound(all((container)), val) - (container).begin()
#define ub(container, val)      upper_bound(all((container)), val) - (container).begin()
#define all(container)          (container).begin(), (container).end()
#define rall(container)         (container).rbegin(), (container).rend()
#define FILL(x, val)            memset(x, val, sizeof(x))
#define sz(container)           ((int) (container).size())
#define pb                      push_back
#define eb                      emplace_back
#define fi                      first
#define se                      second
#define mod                     (long long) 1000000007
#define inf                     INT_MAX
#define INF                     LLONG_MAX

using namespace std;

#ifdef LOCAL_DEFINE
    #include "../../DEBUG.hpp"
#endif

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
long long MAX() {return LLONG_MIN;}
long long MIN() {return LLONG_MAX;}
template<typename T, typename... Args>
T MAX(T a, Args... args) {return max(a, MAX(args...));}
template<typename T, typename... Args>
T MIN(T a, Args... args) {return min(a, MIN(args...));}

typedef long long ll; 
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<long long, long long>> vpll;

int main(void) {    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("in1", "r", stdin);
#endif
    
    int n;
    cin >> n;
    vvll happ(n, vll(3)), dp(n, vll(3, LLONG_MIN));
    forn(i, n) forn(j, 3) cin >> happ[i][j];
    dp[0][0] = happ[0][0];
    dp[0][1] = happ[0][1];
    dp[0][2] = happ[0][2];
    fore(i, 1, n - 1, 1) forn(j, 3) forn(k, 3) if (j != k) uax(dp[i][j], dp[i - 1][k] + happ[i][j]);
    ll ans =  MAX(dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]);
    cout << ans << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << '\n';
#endif
    return 0;
}

Measured memory_bytes: 11264
def xor(n):
    num_pair = (n - 1) // 2
    if num_pair % 2 == 0:
        counter = 1
    else:
        counter = 0

    if n % 2 == 0:
        return n ^ counter
    else:
        return counter


a, b = map(int, input().split())

print(xor(b) ^ xor(a - 1))


Measured memory_bytes: 2940
N, Y = map(int, input().split())
Y //= 1000
z = Y % 5
for zz in range(z, N+1, 5):
    y = (Y-zz)//5 % 2
    for yy in range(y, N-zz+1, 2):
        if (N-zz-yy)*10 == Y-zz-5*yy:
            print(N-zz-yy, yy, zz)
            exit()
else:
    print(-1,-1,-1)


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

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

  for (int i = n-1; i >= 0; i -= 2) {
    cout << a[i] << " ";
  }
  
  if (n % 2) {
    for (int i = 1; i < n; i += 2) {
      cout << a[i] << " ";
    }
  } else {
    for (int i = 0; i < n; i += 2) {
      cout << a[i] << " ";
    }
  } 
  
  cout << endl;

}

Measured memory_bytes: 4020
s = input()
t = input()
sn=[0 for i in range(26)]
tn=[0 for i in range(26)]
for i in range(len(s)):
    sn[ord(s[i])-ord('a')]+=1
    tn[ord(t[i])-ord('a')]+=1
print('Yes' if sorted(sn) == sorted(tn) else 'No')

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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n,x;
  cin >> n >> x;
  vector<int32> a(n);
  REP(i,n)cin >> a[i];
  int64 ans = 0;
  if(a[0] > x){
    ans += a[0] - x;
    a[0] = x;
  }
  FOR(i,1,n){
    if(a[i-1] + a[i] > x){
      int32 eat = a[i-1] + a[i] - x;
      a[i] -= eat;
      ans += eat;
    }
  }
  ANS(ans);
  return 0;
}

Measured memory_bytes: 3968
#include <stdio.h>
#include <string.h>

int main(void)
{
  char s[100001];
  int a = 0;
  int b = 0;
  scanf("%s", s);

  for (int i = 0; i < strlen(s); i++) {
    if (s[i] == '0')
      a++;
    else if (s[i] == '1')
      b++;
  }

  if (a > b)
    printf("%d\n", 2 * b);
  else
    printf("%d\n", 2 * a);
}


Measured memory_bytes: 256
#include <iostream>

 

using namespace std;

 

int main()
{
   int i, a, b, temp;
   for(i=1; i<=3000; a++)
   {
        cin >> a >> b;
        if( a==0 && b==0)
        break;
        if( a > b)
        {
            temp = a;
            a = b;
            b = temp;
        }
        cout << a << " " << b << endl;
   }
}


Measured memory_bytes: 3004
#include <stdio.h>

void printconsole(int A[],int n){
    for (int k = 0; k < n; k++) {
        printf("%d",A[k]);
        if(k != n-1)putchar(' ');
    }
    putchar('\n');
}

void shellsort(int A[],int n){
    
}



void insertionSort(int A[],int n){
    int v,j;
    for (int i = 1; i < n; i++) {
        
        printconsole(A,n);
        v = A[i];
        j = i - 1;
        while(j >= 0 && A[j] > v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
    }
    printconsole(A,n);
}

int main(int argc, const char * argv[]) {
    
    int n;
    int A[100];
    scanf("%d",&n);
    
    for (int i = 0; i < n; i++) {
        scanf("%d",&A[i]);
    }
    
    insertionSort(A, n);
    
    /*
    printf("%d\n",n);
    for (int i = 0; i < n; i++) {
        printf("%d\n",A[i]);
    }
     */

    return 0;
}



Measured memory_bytes: 2064
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int pos[2][2020];
int L[2][2020][2020];
int dp[2020][2020];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,2*N) {
		cin>>s>>x;
		pos[s=="W"][x-1]=i;
	}
	
	FOR(i,2) {
		FOR(x,N) {
			for(y=x+1;y<N;y++) if(pos[i][y]<pos[i][x]) L[i][x][N]++;
			for(y=N-1;y>=0;y--) L[i][x][y]=L[i][x][y+1]+(pos[i^1][y]<pos[i][x]);
		}
	}
	
	FOR(x,N+2) FOR(y,N+2) dp[x][y]=1<<25;
	dp[0][0]=0;
	FOR(x,N+1) FOR(y,N+1) {
		if(x<N) dp[x+1][y]=min(dp[x+1][y],dp[x][y]+L[0][x][y]);
		if(y<N) dp[x][y+1]=min(dp[x][y+1],dp[x][y]+L[1][y][x]);
	}
	
	cout<<dp[N][N]<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 48000