akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define fastio() ios_base::sync_with_stdio(false);
#define rmod(x, y) ((((x)%(y))+(y))%(y))
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
template<typename T, typename R = null_type, typename C = less<T>>
tree<T, R, C, rb_tree_tag, tree_order_statistics_node_update> ordered_set(){
	return tree<T, R, C, rb_tree_tag, tree_order_statistics_node_update>();
}

const int maxn = 1e4+5;
int n;
ll a[maxn], b[maxn];


int main(){
	scanf("%d", &n);
	ll as = 0, bs = 0;
	for(int i = 0; i<n; i++) scanf("%lld", &a[i]), as+= a[i];
	for(int i = 0; i<n; i++) scanf("%lld", &b[i]), bs+= b[i];
	if (as >= bs){
		if(as==bs && equal(a, a+n, b, b+n)) puts("Yes");
		else puts("No");
		return 0;
	}
	ll M = bs-as;
	ll K = 0;
	for(int i = 0; i<n; i++){
		if (a[i]<b[i]) {
			ll movs = (b[i]-a[i]+1ll)/2ll;
			K+= movs;
			a[i]+=movs+movs;
		}
	}
	ll L = M - K;
	if (L<0) {puts("No"); return 0;}
	ll D = 0;
	for(int i = 0; i<n; i++) {
		if (b[i]<a[i]) D+= a[i]-b[i], b[i] = a[i];
	} 
	if (L+L == M-D) puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 384
n,m = map(int,input().split())

c_m = 0
c_v = 0

matrix =[]
vector = []

ans = []

while c_m < n:
    matrix.append([int(n) for n in input().split()])
    c_m += 1

while c_v < m:
    vector.append(int(input()))
    c_v += 1

for N in range(n):
    a = 0
    for M in range(m):
        a += matrix[N][M]*vector[M]

    ans.append(a)

for a in ans:
    print(a)



Measured memory_bytes: 6016
// test.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//


#include <iostream>
#include <algorithm>
#include <vector>




using namespace std;


int main()
{
	// 整数の入力
	int N,K;
	cin >> N >> K;
	vector<int> h(N);
	for (int i = 0; i < N ; i++) {
		cin >>h.at(i);
	}
	
	int answer = 0;
	for (int i = 0; i < N; i++) {
		if (h.at(i) >= K) {
			answer++;
		}
	}
	
	cout << answer << endl;
	
	return 0;
}





// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>

// #define INT_MAX 2147483647
// #define LL_MAX 9223372036854775807

using namespace std;
#define i64  long long

void solve(void)
{
  int A,B;
  cin>>A>>B;
  cout<<max(0,A-B-B);
  return;
}

int main(int argc, const char *argv[])
{

  solve();

  return 0;
}


Measured memory_bytes: 256
#include<set>
#include<map>
#include<list>
#include<queue>
#include<cmath>
#include<vector>
#include<cstdio>
#include<cctype>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define qread(x) x=read()
#define mes(x,y) memset(x,y,sizeof(x))
#define mpy(x,y) memcpy(x,y,sizeof(x))
#define Maxn 100000
#define INF 2147483647
inline int read(){
	int f=1,x=0;char ch;
	while(!(ch>='0'&&ch<='9')){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return f*x;
}
int n,k,ans,tmp,a[Maxn+1];
int main(){
    qread(n),qread(k);
    for(int i=1;i<=n;i++)qread(a[i]);
    ans=INF;
    for(int l=1;l<=n-k+1;l++){
        int r=l+k-1;
        if(a[l]<=0&&a[r]<=0)tmp=abs(std::min(a[l],a[r]));
        else if(a[l]>=0&&a[r]>=0)tmp=std::max(a[l],a[r]);
        else tmp=std::min(abs(a[l])*2+a[r],a[r]*2+abs(a[l]));
        ans=std::min(ans,tmp);
    }
    printf("%d\n",ans);
}


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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loop2(num) for (lli j = 0 ; j < num ; j ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }
#define looppu(num , ar) for (lli i = 0 ; i < num ;  i++) {lli x ; cin >> x ; ar . push_back (x) ;}
#define loopin(num , ar) for (lli i = 0 ; i < num ;  i++) {lli x ; cin >> x ; ar . insert (x) ;}

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back ()
#define pof pop_front ()

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

signed main ()
{
    fastio
    ll a ; cin >> a ;
    vi ve ;
    forr(0 , a + 1){
        if (i % 2 == 1)
            ve . pb (i) ;
    }
    vi cnt(ve.size()) ;
    loop2(ve.size()){
        forr( 1 , a + 1){
            if (ve[j] % i == 0)
                cnt[j] ++ ;
        }
    }
    sort(cnt.begin() , cnt . end() ) ;
    reverse(cnt.begin() , cnt . end() ) ;
    for(int i = cnt . size() - 1 ; i >= 0 ; i--){
        if (cnt[i] != 8) cnt.pob ;
    }
    cout << cnt . size() << endl ;
    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(int i=x;i<y;i++)
#define frr(i,x,y) for(int i=x-1;i>=y;i--)
#define inf 1e18+1
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

void solve()
{
    ll n,m;
    cin>>n>>m;
    int ans=1;
    for(int i=1;i*i<=m;i++)
    {
        if(m%i==0)
        {
            if(m/i>=n)
            {
                ans=max(ans,i);
            }
            int x=m/i;
            if(m/x>=n)
            {
                ans=max(ans,x);
            }
        }
    }
    cout<<ans<<endl;
    return;
}
int main()
{
    IOS;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        //cout<<"Case #"<<pp-t<<":\n";
        solve();
    }
    return 0;
}
/* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
*/
/*
recursion - matrix exponential

*/
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algorithm

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;

long long GCD(long long x,long long y){


while(1){
if(x<y)swap(x,y);
if(!y)break;
x%=y;
}

return x;

}


int main(){

int N;
cin>>N;
long long x;
cin>>x;
long long toshi[N];
rep(i,N)cin>>toshi[i];

long long diff[N];
rep(i,N){
diff[i]=abs(toshi[i]-x);
}
long long gcd=diff[0];
rep(i,N){
gcd=GCD(gcd,diff[i]);
}
cout<<gcd<<endl;
 return 0;
}
/*
3 3
1 7 11

2

3 81
33 105 57

24

1 1
1000000000

999999999
*/

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N, K;
  cin>>N>>K;
  queue<int> q;
  q.push(1);
  for(int i=0;i<N;i++) {
  	int size=q.size();
  	for(int j=0;j<size;j++) {
  		int t=q.front();
  		q.pop();
  		q.push(t*2);
  		q.push(t+K);
  	}
  }
  int min=q.front();
  q.pop();
  while(!q.empty()) {
  	if (q.front() < min)
  		min = q.front();
  	q.pop();
  }
  cout << min << endl;
}


Measured memory_bytes: 256
#include <cassert>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " <<"LINE:"<<__LINE__<<"  "<< #i <<":"<< i << std::endl

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }
 
  long long x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P = std::pair<ll, ll>;

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

  ll h,w;
  std::cin>>h>>w;

  std::vector<std::vector<ll>> dp(h,std::vector<ll>(w,0));

  dp[0][0]=1;

  rep(i,0,h){
    std::string s;
    std::cin>>s;

    rep(j,0,w){
      if(s[j]=='.'){
        if(0<=j-1)dp[i][j]=(dp[i][j]+dp[i][j-1])%MOD;
        if(0<=i-1)dp[i][j]=(dp[i][j]+dp[i-1][j])%MOD;
      }
    }
  }

  std::cout<<dp[h-1][w-1]<<"\n";

  return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define loop(n, i) for(int i=0;i<n;i++)
#define loop1(n, i) for(int i=1;i<=n;i++)
#define rloop(n, i) for(int i=n;i;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;

const long long mod1 = 999999937LL, mod2 = 1000000007LL, base = 9973;

int main() {
    int n; cin >> n;
    string S; cin >> S;
    V<ll> hash1(n), hash2(n);

    loop (n, i) {
        hash1[i] = S[i];
        hash2[i] = S[i];
    }

    int l = 0, r = n;
    while (r - l > 1) {
        int i = (l + r) / 2;
        int found = 0;
        unordered_set<ll> set1, set2;
        ll pow1 = 1, pow2 = 1;
        loop (i, j) {
            pow1 = (pow1 * base) % mod1;
            pow2 = (pow2 * base) % mod2;
        }
        hash1[0] = S[0] % mod1;
        hash2[0] = S[0] % mod2;
        loop1 (n - 1, j) {
            hash1[j] = (hash1[j - 1] * base + S[j]) % mod1;
            hash2[j] = (hash2[j - 1] * base + S[j]) % mod2;
            if (j - i >= 0) {
                hash1[j] -= (S[j - i] * pow1) % mod1;
                hash1[j] = (hash1[j] + mod1) % mod1;
                hash2[j] -= (S[j - i] * pow2) % mod2;
                hash2[j] = (hash2[j] + mod2) % mod2;
            }
        }
        for (int j = i; j < n; j++) {
            set1.insert(hash1[j - i]);
            set2.insert(hash2[j - i]);
            if (set1.find(hash1[j]) != set1.end() &&
                set2.find(hash2[j]) != set2.end()) {
                found = 1;
            }
        }
        if (found) l = i;
        else r = i;
    }
    cout << l << endl;

    return 0;
}



Measured memory_bytes: 816
/*
ЗАПУСКАЕМ
░ГУСЯ░▄▀▀▀▄░РАБОТЯГУ░░
▄███▀░◐░░░▌░░░░░░░
░░░░▌░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░▄▀▒▒▀▀▀▀▄
░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░▄▄▌▌▄▌▌░░░░░
 */
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
 
using namespace std;
template<typename T1, typename T2>inline void chkmin(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void chkmax(T1 &x, T2 y) { if (x < y) x = y; }
#define sz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define left left224
#define right right224
#define next next224
#define rank rank224
#define prev prev224
#define y1 y1224
#define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout)
#define files(FILENAME) read(FILENAME), write(FILENAME)
#define pb push_back
#define mp make_pair
const string FILENAME = "input";
const int MAXN = 505;


// class complex {
//     long double image, real;
// public:
//     long double getImage() {
//         return image;
//     }
//     long double getReal() {
//         return real;
//     }

// };


int n;
int a[MAXN][MAXN];
long long s1[MAXN][MAXN], s2[MAXN][MAXN], dp[MAXN][MAXN];


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   // read(FILENAME);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n - 1; j++) {
            cin >> a[i][j + (i <= j)];
        }
    }
    for (int i = 1; i <= n; i++) {
        long long sum1 = 0, sum2 = 0;
        for (int j = i; j <= n; j++) {
            sum1 += a[i][j];
            sum2 += a[j][i];
            s1[i][j] = s1[i - 1][j] + sum1;
            s2[i][j] = s2[i - 1][j] + sum2;
        } 
    }
    for (int i = 0; i <= n + 1; i++) {
        for (int j = 0; j <= n + 1; j++) {
            dp[i][j] = 1e18;
        }
    }
    for (int i = 2; i <= n; i++) {
        dp[i][1] = s1[i - 1][i - 1];
    }
    for (int i = 2; i <= n; i++) {
        for (int j = 1; j <= i - 1; j++) {
            for (int x = i + 1; x <= n; x++) {
                long long sum1 = s1[x - 1][x - 1] - s1[i - 1][x - 1];
                long long sum2 = s2[i - 1][n] - s2[j - 1][n] - s2[i - 1][x - 1] + s2[j - 1][x - 1];
                chkmin(dp[x][i], dp[i][j] + sum1 + sum2);
            }
        }
    }
    long long ans = s1[n][n];
    for (int i = 2; i <= n; i++) {
        for (int j = 1; j <= i - 1; j++) {
            chkmin(ans, dp[i][j] + s1[n][n] - s1[i - 1][n]);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7168
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<string> s(n);

	int cnt = n;
	for(int i=0;i<n;i++){
		cin >> s.at(i);
	}
	sort(s.begin(),s.end());
	for(int i=0;i<n-1;i++){
		if(s.at(i)==s.at(i+1)){
			cnt--;
		}
	}
	cout << cnt << endl;
}


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


int main(){

  int E,Y;
  cin>>E>>Y;

if(E == 1) cout<<Y+1867<<endl;
if(E == 2) cout<<Y+1911<<endl;
if(E == 3) cout<<Y+1925<<endl;
if(E == 4) {cout<<Y+1988<<endl;}
if(E == 0 && 1868 <= Y && Y <= 1911) cout<<"M"<<(Y-1867)<<endl;
if(E == 0 && 1912 <= Y && Y <= 1925) cout<<"T"<<(Y-1911)<<endl;
if(E == 0 && 1926 <= Y && Y <= 1988) cout<<"S"<<(Y-1925)<<endl;
if(E == 0 && 1989 <= Y && Y <= 2016) cout<<"H"<<(Y-1988)<<endl;

 return 0;
}


Measured memory_bytes: 3092
n = gets.chomp.to_i
cnt = 0
cnt_b = 0
cnt_a = 0
cnt_ba = 0
s = []
n.times do |i|
  s[i] = gets.chomp
  (s[i].length-1).times do |j|
    if s[i][j] == "A"
      cnt += 1 if s[i][j+1] == "B"
    end
  end
  if s[i][0] == "B" && s[i][-1] == "A"
    cnt_ba += 1
  end
  if s[i][0] == "B"
    cnt_b += 1
  end
  if s[i][-1] == "A"
    cnt_a += 1
  end
end
if [cnt_b, cnt_a].max == cnt_ba && cnt_ba > 0
  cnt += [cnt_b, cnt_a].min - 1
else
  cnt += [cnt_b, cnt_a].min
end
puts cnt


Measured memory_bytes: 2684
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		int num1, num2;
		int flg = 0;
		
		Scanner sc = new Scanner(System.in);

		while(true){
			String formula = sc.nextLine();
			
			String[] operation = formula.split(" ", 0);
			num1 = Integer.parseInt(operation[0]);
			num2 = Integer.parseInt(operation[2]);

			switch(operation[1]){
				case "+":
					System.out.println(num1 + num2);
					break;
				case "-":
					System.out.println(num1 - num2);
					break;
				case "*":
					System.out.println(num1 * num2);
					break;
				case "/":
					System.out.println(num1 / num2);
					break;
				default :
					flg = 1;
					break;
			}
			if(flg == 1) break;
		}

	}
}


Measured memory_bytes: 26156
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>>vvi;

int main(){
  string s; int q;
  cin>>s>>q;
  vector<int>t(q);
  vector<int>f(q);
  vector<char>c(q);
  rep(i,q){
    cin>>t[i];
    if(t[i]==2)cin>>f[i]>>c[i];
  }
  vector<int>count(q);
  int sum=0;
  rep(i,q){
    if(t[i]==1)sum++;
    count[i]=sum;
  }
  string be="";
  string en="";
  rep(i,q){
    if(t[i]==1)continue;
    if((count[q-1]-count[i]+f[i])%2==0){
      en+=c[i];
    }
    else {
      be+=c[i];
    }
  }
  reverse(be.begin(),be.end());
  if(count[q-1]%2!=0)reverse(s.begin(),s.end());
  cout<<be+s+en<<endl;
}
  
  
  

Measured memory_bytes: 3908
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y)* mod_pow(kai(y, y), mod - 2, mod) % mod;
}
struct edge { int to, cost; };
int n;
int a[114514];
signed main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	int ans = 0;
	rep(i, n - 1) {
		if (a[i] >= a[i + 1])ans++;
	}
	cout << ans + 1 << endl << n << endl;
	ggr
}



Measured memory_bytes: 3888
#include<bits/stdc++.h>
#define int long long

using namespace std;

int32_t main(){

int n;	cin>>n;
int arr[n];
for(int i=0; i<n; i++){
cin>>arr[i];
if(!arr[i]){
	cout<<"0"<<endl;
	return 0;
}
}
int mul=1;
bool flag = false;
for(int i=0; i<n; i++){
	
	if(arr[i]<=1000000000000000000/mul){
		mul*=arr[i];
	}	
	else{
		cout<<"-1"<<endl;
		return 0;
	}
}

cout<<mul<<endl;


return 0;
}

Measured memory_bytes: 4324
#include <bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int,int>
const int mod=1e9 + 7;
 
int dx[]={-1, 0, 1, 0};
int dy[]={0, -1, 0, 1};
 
 

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


  int n,x;
  cin>>n>>x;

  if(n*500>=x)cout<<"Yes\n";
  else cout<<"No";
 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int x,y;
  if(c%b!=0) x=c/b+1;
  else x=c/b;
  
  if(a%d!=0) y=a/d+1;
  else y=a/d;
  
  if(x<=y) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3620
def main():
    N = int(input())
    A = list(map(int, input().split()))
    C = [0] * (10 ** 5)
    for a in A:
        C[a] += 1
    ans = 0
    for i in range(len(C) - 2):
        ans = max(ans, C[i] + C[i + 1] + C[i + 2])
    print(ans)


main()


Measured memory_bytes: 14092
import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.util.Arrays;
import java.util.Collections;
import java.util.ArrayList;
import java.util.List;
import java.util.HashSet;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.util.Comparator;

public class Main {
    // 標準入力
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    // 標準入力数値配列用 int
    static int[] inputval() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        int[] intarray = new int[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    // 標準入力数値リスト用 int
    static List<Integer> inputIntList() throws Exception {
        List<String> strList = Arrays.asList(br.readLine().trim().split(" "));
        List<Integer> intList = new ArrayList<Integer>();
        for (String elem : strList){
            intList.add(Integer.parseInt(elem));
        }
        return intList;
    }

    // 標準入力数値配列用 integer ソート用
    static Integer[] inputvalInteger() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        Integer[] intarray = new Integer[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    public static void main(String[] args) throws Exception {
        // write your code here
        int n = Integer.parseInt(br.readLine());
        for (int i=0; i<= n/4+1;i++){
            // 4の倍数の時も、後半の条件が0%7で0の条件に合致する.
            if (n >= i * 4 && (n - i * 4) % 7 == 0) {
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");

    }

}



Measured memory_bytes: 32472
#include <string>
#include <stack>
#include <iostream>
using namespace std;

int main() {
  string word;
  stack<int> S;
  while (cin >> word) {
    if (word == "+") {
      int num0,num1;
      num0 = S.top(); S.pop();
      num1 = S.top(); S.pop();
      S.push(num0+num1);
    }
    else if (word == "-") {
      int num0,num1;
      num0 = S.top(); S.pop();
      num1 = S.top(); S.pop();
      S.push(num1-num0);
    }
    else if (word == "*") {
      int num0,num1;
      num0 = S.top(); S.pop();
      num1 = S.top(); S.pop();
      S.push(num0*num1);
    }
    else {
      S.push(stoi(word));
    }
  }
  cout << S.top() << endl;
}

Measured memory_bytes: 1204
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define P_B push_back
#define PO_B pop_back
#define E_B emplace_back
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << endl

using namespace std;
using ll = long long;
using Pii = pair<int,int>;
using Pll = pair<ll,ll>;
using VI = vector<int>;
using VL = vector<ll>;
using VVI = vector<vector<int> >;
using VVL = vector<vector<ll> >;
//int dx[4] = {1, 0, -1, 0};
//int dy[4] = {0, 1, 0, -1};
//const ll LINF = (ll)1e18 - 1;
//const int INF = 1e9 - 1;

// index が条件を満たすかどうか
bool isOK(vector<Pii> &A, int index, int key) {
    if (A[index].fi >= key) return true;
    else return false;
}

// 汎用的な二分探索のテンプレ
int L_B(vector<Pii> &A, int key) {
    int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int right = (int)A.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1) {
        int mid = left + (right - left) / 2;

        cout << left << " ~ " << right << " : " << mid << " ||| " << isOK(A, mid, key) << endl;

        if(isOK(A, mid, key)) right = mid;
        else left = mid;
    }

    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return right;
}



void Main(){
  ll N, M, ans=0;
  cin >> N >> M;
  vector<Pii> A(M);
  rep(i, M){
    //seにA[i],fiにB[i]を格納
    cin >> A[i].se >> A[i].fi;
  }

  sort(all(A));

  ll now = A[0].fi, count = 1;
  bool done = true;
  rep(i, M){
    if(A[i+1].fi == A[i].fi && done) continue;
    if(A[i+1].fi > A[i].fi) done = false;
    if(now <= A[i+1].se){
      count++;
      now = A[i+1].fi;
      done = true;
    }
  }

  cout << count << endl;



}

int main()
{

	Main();

  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
int main()
{
    char str[100];
     scanf("%s",&str);
  int length=strlen(str);
  if(length==6)
  {
    if(str[2]==str[3]&&str[4]==str[5])
   {
       printf("Yes\n");
   }
   else
   {
       printf("No\n");
   }
  }
   return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 1000005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define pii pair<int,int>
const int mod = 1e9 + 7;
ll pre[maxn];
ll inv[maxn];
ll prei[maxn];
void build(int n){
    pre[1] = pre[0] = 1, inv[1] = inv[0] = 1, prei[1] = prei[0] = 1;
    for(int i = 2 ; i <= n ; i++){
        pre[i] = pre[i-1] * i % mod;
        inv[i] = (mod - mod / i * inv[mod % i] % mod) % mod;
        prei[i] = prei[i-1] * inv[i] % mod;
    }
}
ll C(int n, int k){
   return pre[n] * prei[k] % mod * prei[n-k] % mod;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    build(n+50);
    ll ans = 1;
    for (int i = 2 ; i <= sqrt(m) ; i++) {
        if (m % i)continue;
        int cnt = 0;
        while (m % i == 0) {
            m /= i;
            cnt++;
        }
        ans *= C(cnt+n-1,n-1);
        ans %= mod;
    }
    if (m > 1) {
        ans *= n;
        ans %= mod;
    }
    cout << ans << '\n';

}

Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector
;
#define vvec(s) vector<vector
> ;
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vector<int> v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli n;
    cin>>n;
    if(n==0){
        cout<<0<<endl;
        return 0;
    }
    vi ans;
    lli i=1;
    while(n!=0){
        lli now=pow(-2,i);
        if(abs(n)%abs(now)!=0){
            ans.push_back(1);
            n-=pow(-2,i-1);
        }
        else{
            ans.push_back(0);
        }
        i++;
    }
    reverse(all(ans));
    rep(i,ans.size()){
        cout<<ans[i];
    }
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc179/tasks/abc179_a
// 解説放送
// back

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

int main()
{
    string s;
    cin >> s;
    if (s.back() == 's')
        s += "es";
    else
        s += "s";

    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<iostream>

using namespace std;

int main()
{
    string s;
    cin >> s;

    if (s[0] == s[1] && s[0] == s[2] && s[1] == s[2]) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Control.Applicative

solve :: Int -> Int -> String
solve n x =
    "Case " ++ show n ++ ": " ++ show x

main =
    mapM_ putStrLn =<< (zipWith solve [1..]) . takeInputs . lines <$> getContents
    where
    takeInputs :: [String] -> [Int]
    takeInputs = takeWhile (/= 0) . map read

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

using namespace std;

int x,a,b,c;
int main(){
	while(cin>>a>>b>>c>>x){
		int cnt = 0;
		for(int i=0; i<=c; ++i){//c
			for(int j=0; j<=b; ++j){
				for(int k=0; k<=a; ++k){
					if(x == 50*i + 100*j + 500*k)cnt++;
				}
			}	
		}
		cout<<cnt<<endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define dame {cout<< "No" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------


ll GCD(ll a, ll b) { // 0はすべての倍数とする
    if (b == 0) return a;
    else return GCD(b, a%b);
}
struct ST{
    int N;
    vector<ll> dat;

    ST(int n) {
        N = 1;
        while(N < n) N <<= 1;
        dat.resize(2*N-1, 0); //和なら0
    }

    void update(int x, ll val) { // 0-indexed
        x += (N - 1); //最下段に移動
        dat[x] = val;
        while(x > 0) { //上に向かって更新
            x = (x - 1) / 2;
            dat[x] = GCD(dat[2*x+1], dat[2*x+2]); //和なら足す
            //cout<< x <<dat[x] <<"\n";
        }
    }

    ll getgcd(int a, int b, int k=0, int l=0, int r=-1) {
        // [a,b)をみる。現在k,範囲[l,r)。0-indexed。
        if(r<0) r=N;
        if(r <= a or b <= l) return 0; //範囲外 和なら0
        if(a <= l and r <= b) return dat[k]; //被覆
        ll vl = getgcd(a, b, 2*k+1, l, (l+r)/2);
        ll vr = getgcd(a, b, 2*k+2, (l+r)/2, r);
        return GCD(vl, vr); //和なら足す
    }
};

//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    vector<ll> A(N);
    rep(i,N) cin>>A[i];
    ST st(N);
    rep(i,N) st.update(i,A[i]);
    ll ans=1;
    rep(i,N){
        maxi(ans,GCD(st.getgcd(0,i),st.getgcd(i+1,N)));
    }
    cout<< ans <<"\n";
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 3072
n = int(input())
xl = [[int(i) for i in input().split(' ')] for j in range(n)]

ls = sorted([[i-j, i+j] for i, j in xl], key=lambda x: x[1])

i, dr = 0, 0
while True:
    if (len(ls)<=1) | (i+1 >= len(ls)):
        break
    a, b = ls[i], ls[i+1]
    if a[1]>b[0]:
        dr += 1
        ls.pop(i+1)
    else:
        i += 1

print(len(ls))

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

int main() {
    int n;
    cin >> n;

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

    sort(sort_x, sort_x + n);

    int a = sort_x[n/2 - 1];
    int b = sort_x[n/2];

    for (int i = 0; i < n; i++) {
        if (x[i] < b) {
            cout << b << endl;
        }
        else {
            cout << a << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3712
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<cctype>
#include <cstring>
using namespace std;

int main(){
char str1[100],str2[100],str3[200];
scanf("%s\n%s", str1, str2);

int length = strlen(str1);
strcpy(str3, str1); 
strcat(str3, str1);  // 文字列 str1 に文字列 str2 を連結する

if ( strstr(str3, str2) == NULL ) printf("No\n");
else printf("Yes\n");

return 0;
}


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

int main(void) {
    string a;
    int cnt = 0;
    cin >> a ;

    for(int i = 0; i < a.length() + 1; i++){
    switch (a[i])
    {
    case '1':
    cnt += 1;
        break;

    case '0':
        break;
        }
    }

    cout << cnt << endl;


    return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A.at(i);
    int hoge = A.at(0);
    for (int i = 1; i < N; i++) {
        hoge ^= A.at(i);
    }
    for (int i = 0; i < N; i++) cout << (hoge ^ A.at(i)) << endl;
}

Measured memory_bytes: 4024
#include <stdio.h>

int searchabc(char st[]){
	int i=0;
	while(st[i] != '\0'){
		if(st[i] != 'o'){
			return i;
		}
		i++;
	}
	return -1;
}

int main(void){
	char s[3][100];
	char box;
	int t=0,i=0;
	scanf("%s %s %s",s[0],s[1],s[2]);
	while(1){
		i = searchabc(s[t]);
		if(i == -1){
			break;
		}else{
			box = s[t][i];
			s[t][i] = 'o';
		}
		if(box == 'a')t = 0;
		else if(box == 'b')t = 1;
		else t = 2;
	}
	if(t == 0)printf("A\n");
	else if(t == 1)printf("B\n");
	else printf("C\n");
	return 0;
}

Measured memory_bytes: 128
//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(int i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int main(){
	ll x,y,a,b,c;cin>>x>>y>>a>>b>>c;
	ll A[a],B[b],C[c];
	for(int i=0;i<a;i++)cin>>A[i];
	for(int i=0;i<b;i++)cin>>B[i];
	for(int i=0;i<c;i++)cin>>C[i];
	sort(A,A+a);
	reverse(A,A+a);
	sort(B,B+b);
	reverse(B,B+b);
	sort(C,C+c);
	reverse(C,C+c);
	ll sum=0;
	vi v;
	for(int i=0;i<x;i++){
		sum+=A[i];
		v.push_back(A[i]);
	}
	for(int i=0;i<y;i++){
		sum+=B[i];
		v.push_back(B[i]);
	}
	sort(v.begin(),v.end());
	ll sum1=0,sum2=0,ans=sum;
	for(int i=0;i<min(c,x+y);i++){
		sum1+=v[i];
		sum2+=C[i];
		ans=max(ans,sum-sum1+sum2);
	}	
	cout<<ans<<endl;
}


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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define mp make_pair
#define ll long long
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 100010
#define inf 1e9

bool flag[1100002];
vector<ll> p;

void siv()
{

    ll N = 1000000;
    ll val = sqrt(N)+1;
    for(ll i = 4; i <= N; i+=2) flag[i] = 1;
    for(ll i = 3; i < val; i+=2)
    {

        if(flag[i] == 0)
        {

            for(ll j = i*i; j <= N; j+=i) flag[j]=1;
        }
    }
    for(ll i = 2; i <= 1000000; i++)
    {

        if(flag[i]==0) p.pb(i);
    }
}

int main()
{

    siv();
    ll n;
    cin >> n;
    for(ll i = 0; i < p.size(); i++)
    {

        if(p[i] >= n)
        {

            cout << p[i];
            return 0;
        }
    }
}


Measured memory_bytes: 2424
n=int(input())
ans=0
l=[int(input()) for i in range(n)]
from collections import Counter
lst=list(Counter(l).values())
def mod2(n):
  if n%2==1:
    return 1
  else:
    return 0
ans=0
for i in lst:
  ans+=mod2(i)
print(ans)
  


Measured memory_bytes: 16660
#include<bits/stdc++.h>
using namespace std;
bool check(int possible , vector<vector<pair<int , int>>> & all , int &n){

    for(int i = 0; i < n; ++i){
        if((possible & (1 << i)) != 0){
            int k = all[i].size();
            for(int j = 0; j < k; ++j){
                int person , type;
                person = all[i][j].first , type = all[i][j].second;
                int exist = ((possible & (1 << person)) != 0) ? 1 : 0;

                if(exist != type){
                    return false;
                }
            }
        }
    }
    return true;
}
int main(){

    int n;
    cin >> n;
    vector<vector<pair<int,int>>>all(n);

    for(int i = 0; i < n; ++i){

        int ai;
        cin >> ai;
        int pp = ai;
        while(pp--){
            int xi , yi;
            cin >> xi >> yi;
            --xi;
            all[i].push_back({xi , yi});
        }
    }
    int limit = (1 << n) - 1;
    int maxvalue = 0;
    for(int i = 0; i <= limit; ++i){
        if(check(i , all , n)){
            maxvalue = max(maxvalue , __builtin_popcount(i));
        }
    }
    cout << maxvalue << "\n";

return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include<iomanip>

using namespace std;
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define i64 int64_t
#define tos(x) to_string(x)

int main() {
	int n, m;
	cin >> n >> m;
	cout << (n - 1) * (m - 1) << endl;
	return 0;
}

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

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


// std::vector Declaration
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
   return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// std::vector Initialization
template<typename T>
void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U>
void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

// std::vector Debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
   os << "[";
   bool a = 1;
   for (auto e : v ) {
      os << (a ? "" : " "); 
      os << e;
      a = 0;
   }
   os << "]";
   return os;
}

// std::pair Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
   os << "(" << p.first << " " << p.second << ")";
   return os;
}

// std::set Debug
template<typename T>
ostream& operator<<(ostream& os, const set<T>& st) {
   os << "{";
   bool a = 1;
   for (auto e : st) {
      os << (a ? "" : " ");
      os << e;
      a = 0;
   }
   os << "}";
   return os;
}

// std::map Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& mp) {
   os << "{";
   bool a = 1;
   for (auto e : mp) {
      os << (a ? "" : " ");
      os << e.first << ":" << e.second;
      a = 0;
   }
   os << "}";
   return os;
}

// std::tuple Debug
template<int N,class Tuple>
void out(ostream &os,const Tuple &t){}
template<int N,class Tuple,class H,class ...Ts>
void out(ostream &os,const Tuple &t){
   if(N)os<<" ";
   os<<get<N>(t);
   out<N+1,Tuple,Ts...>(os,t);
}
template<class ...Ts>
ostream& operator<<(ostream &os, const tuple<Ts...> &t){
   os<<"(";
   out<0,tuple<Ts...>,Ts...>(os,t);
   os<<")";
   return os;
}

// Debug
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl

struct edge { int to, cost; };

const LL LINF = 1LL<<60;
const int IINF = 1<<30;
const LL MOD = 1e9+7;

LL power(LL x, int n) {
   LL res = 1;
   while (n > 0) {
      if ((n & 1) == 1) res *= x;
      x *= x;
      n >>= 1;
   }
   return res;
}

int main()
{
   int n, k; cin >> n >> k;

   double sum = 0;
   for (int i = 1; i <= n; ++i) {
      int m = 0;
      if (i < k) {
         m = log((double)k/i)/log(2);
         if (power(2,m) * i != k) {
            ++m;
         }
      }

      sum += pow(0.5, m);
   }
   sum /= n;
   printf("%.9lf\n", sum);

   return 0;
}


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

int main(void){
   string S;
   cin>>S;
   int N=S.size();
   vector<int> A(N+1,0);
   for(int i=0;i<N;i++){
      if(S[i]=='<'){
         A[i+1]=max(A[i+1],A[i]+1);
      }
   }
   for(int i=N-1;i>=0;i--){
      if(S[i]=='>'){
         A[i]=max(A[i+1]+1,A[i]);
      }
   }
   long long ans=0;
   for(int i=0;i<N+1;i++){
      ans+=A[i];
   }
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 5828
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
int main() {
    int m,k;cin >>  m >> k;
    lli ma = (1 << m) - 1;
    if(ma < k){
        cout << -1  << endl;
        return 0;
    }
    if(k==0){
        rep(i,1<<m){
            cout <<  i << " ";
        }
        rrep(i,1<<m){
            cout <<  i << " ";
        }
        return 0;
    }
    lli tmp = 0;
    rep(i,1<<m){
        if(i != k){
            tmp ^= i;
        }
    }
    if(tmp !=k){
        cout << -1 << endl;
        return 0;
    }
    cout << k <<  " ";
    rep(i,1 << m){
    if(i != k){
        cout << i << " ";
        }
    }
    cout << k <<  " ";
    rrep(i,1 << m){
    if(i != k){
        cout << i << " ";
        }
    }
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<set>
#include<unordered_set>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<tuple>
#include<iomanip>
#include<climits>
#define ll long long int
#define mod 1000000007
#define pi acos(-1)
using namespace std;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int a , b;
  cin>>a>>b;
  if(a+b==3)
    cout<<3;
  else if(a+b==4)
  {
    cout<<2;
  }
  else
  {
    cout<<1;
  }
  
  
  return 0;
}

Measured memory_bytes: 256
#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(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll 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;
}

ll mul(ll d){
  ll a=d%10,b=d/10;
  return a*b;
}
void solve(long long M, long long D){
  ll ans=0;
  for (size_t i = 1; i <= M; i++)
  {
    for (size_t j = 1;j <= D; j++){
      ll a=j%10,b=j/10;
      if(a>=2&&b>=2&&mul(j)==i){
        dump(i);
        dump(j);
        ++ans;
      }
    }
  }
  cout<<ans<<endl;
}

int main(){
    long long M;
    scanf("%lld",&M);
    long long D;
    scanf("%lld",&D);
    solve(M, D);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define Lson L, mid, rt<<1
#define Rson mid+1, R, rt<<1|1
const int maxn=1e5+10;
using namespace std;
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}
int n,m,k,t,a,b,c;
int main()
{
    int i,j;
    scanf("%d%d%d",&a,&b,&c);
    printf("%lld\n",min({(ll)abs(a/2*2-a)*b*c,(ll)abs(b/2*2-b)*a*c,(ll)abs(c/2*2-c)*a*b}));
    //system("Pause");
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);//スキャナー作る
		StringBuilder all = new StringBuilder();//合計用？変数
		StringBuilder out = new StringBuilder();//表示用変数
		
		while(true){//----------------------------------------------------------------------+
			int h = sc.nextInt();//縦取り込み
			int w = sc.nextInt();//横取り込み
			if((h + w) <= 0){break;}//入力が 0 0 なら 繰り返し終了 
				for(int j = 0; j < h; j++){//縦の計算-----------------------------------++
					for(int i = 0; i < w; i++){//横の計算//-----------------------+++
						out = out.append("#");//out に横の数ぶん＃格納
					}//-----------------------------------------------------------+++
					out = out.append("\n");//outに改行コード格納
				}//---------------------------------------------------------------------++
			all = all.append(out + "\n");//格納した文字列と改行文字をallに格納
			out.delete(0, out.length());//outを初期化
		}//---------------------------------------------------------------------------------+
		System.out.print(all);//0 0が入力されループ抜けたのでallに格納された全てを表示
	}
}

Measured memory_bytes: 23700
#include <bits/stdc++.h>
using namespace std;
 
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; }
 
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;
 
const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;
 
const int MAX = 1000000;
const int MOD = 1000000007;
 
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll modPow(ll a, ll n, ll p) {
  if (n == 0) return 1;
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  ll t = modPow(a, n / 2, p);
  return (t * t) % p;
}
ll choose(ll n, ll r, ll mod){
    ll mul = 1, div = 1;
    for(ll i = 0; i < r; i++){
        mul *= n - i;
        div *= i + 1;
        mul %= mod;
        div %= mod;
    }   
    return mul * modPow(div, mod - 2, mod) % mod;
}
 
int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>>a(100100);
    rep(i, 0, n){
        int p, q;
        cin >> p >> q;
        a[p].push_back(q);
    }
    int ans = 0;
    priority_queue<int>que;
    rep(i, 1, m+1){
        for(auto j:a[i])que.push(j);
        int b = que.size();
        if(b){
            ans += que.top();
            que.pop();
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 8740