akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
using namespace std;

int main(void)
{
	string str;
	
	map<string,string> encode;
	map<string,string> decode;
	
	encode[" "] = "101";
	encode["'"] = "000000";
	encode[","] = "000011";
	encode["-"] = "10010001";
	encode["."] = "010001";
	encode["?"] = "000001";
	encode["A"] = "100101";
	encode["B"] = "10011010";
	encode["C"] = "0101";
	encode["D"] = "0001";
	encode["E"] = "110";
	encode["F"] = "01001";
	encode["G"] = "10011011";
	encode["H"] = "010000";
	encode["I"] = "0111";
	encode["J"] = "10011000";
	encode["K"] = "0110";
	encode["L"] = "00100";
	encode["M"] = "10011001";
	encode["N"] = "10011110";
	encode["O"] = "00101";
	encode["P"] = "111";
	encode["Q"] = "10011111";
	encode["R"] = "1000";
	encode["S"] = "00110";
	encode["T"] = "00111";
	encode["U"] = "10011100";
	encode["V"] = "10011101";
	encode["W"] = "000010";
	encode["X"] = "10010010";
	encode["Y"] = "10010011";
	encode["Z"] = "10010000";
	
	decode["00000"] = "A";
	decode["00001"] = "B";
	decode["00010"] = "C";
	decode["00011"] = "D";
	decode["00100"] = "E";
	decode["00101"] = "F";
	decode["00110"] = "G";
	decode["00111"] = "H";
	decode["01000"] = "I";
	decode["01001"] = "J";
	decode["01010"] = "K";
	decode["01011"] = "L";
	decode["01100"] = "M";
	decode["01101"] = "N";
	decode["01110"] = "O";
	decode["01111"] = "P";
	decode["10000"] = "Q";
	decode["10001"] = "R";
	decode["10010"] = "S";
	decode["10011"] = "T";
	decode["10100"] = "U";
	decode["10101"] = "V";
	decode["10110"] = "W";
	decode["10111"] = "X";
	decode["11000"] = "Y";
	decode["11001"] = "Z";
	decode["11010"] = " ";
	decode["11011"] = ".";
	decode["11100"] = ",";
	decode["11101"] = "-";
	decode["11110"] = "'";
	decode["11111"] = "?";
	
	while (getline(cin, str)){
		string a;
		for (int i = 0; i < str.size(); i++){
			a += encode[str.substr(i, 1)];
		}
		a += "0000";
		string res;
		for (int i = 0; i+5 <= a.size(); i+=5){
			res += decode[a.substr(i, 5)];
		}
		cout << res << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int nn;
vector<string> ans;

void solve(string s, int c, int n) {
	if(n == nn) {ans.push_back(s); return;}
	rep(i, c) {
		string t = s;
		t += 'a' + i;
		solve(t, c, n+1);
	}
	string t = s;
	t += 'a' + c;
	solve(t, c+1, n+1);
	return;
}

int main() {
//	cout << fixed << setprecision(15);
	cin >> nn;
	string s = "";
	solve(s, 0, 0);
	for(auto t: ans) cout << t << endl;
}


Measured memory_bytes: 7796
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#define PI 3.14159265359
typedef long long ll;
const int MOD = 1e9+7;
const ll LLINF = 7e18;
using namespace std;

int w[4];
vector<int> v[4];
vector<ll> sum[4];

int main(){
	ll n, w_max, w1, v1;
	cin >> n >> w_max;
	cin >> w1 >> v1;
	w[0]++;
	v[0].push_back(v1);
	for (int i = 1; i < n; i++){
		int temp;
		cin >> temp >> v1;
		w[temp-w1]++;
		v[temp-w1].push_back(v1);
	}
	
	for (int i = 0; i < 4; i++){
		sort(v[i].begin(), v[i].end(), greater<int>());
	}

	for (int i = 0; i < 4; i++){
		sum[i].push_back(0);
	}
	for (int i = 0; i < 4; i++){
		for (int j = 0; j < v[i].size(); j++){
			sum[i].push_back(sum[i][j] + v[i][j]);
		}
	}
	ll ans = 0;
	for (int i = 0; i <= w[0]; i++){
		for (int j = 0; j <= w[1]; j++){
			for (int k = 0; k <= w[2]; k++){
				for (int l = 0; l <= w[3]; l++){
					ll tmp = j + 2*k + 3*l + w1*(i+j+k+l);
					if (tmp <= w_max){
						ans = max(ans, sum[0][i] + sum[1][j] + sum[2][k] + sum[3][l]);
					}
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3596
let ans s =
  let len = String.length s - 1 in
  let all = 1 lsl len in
  let rec f ret i =
    if i = all then ret
    else
      let ioc n = int_of_char n - int_of_char '0' in
      let rec g ret j x k =
        if j = len then ret+x
        else if (k land 1) = 1 then g (ret+x) (j+1) (ioc s.[j+1]) (k lsr 1)
        else g ret (j+1) (10 * x + ioc s.[j+1]) (k lsr 1)
      in f (ret + g 0 0 (ioc s.[0]) i) (i+1)
  in f 0 0;;

Scanf.scanf "%s" (fun s -> print_int (ans s))


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,k,g=0,h,c=1;
  cin>>n>>k;
  vector<int> v(n);
  for(int i=0;i<n;i++){
    cin>>v.at(i);
    v.at(i)--;
  }
  if(n>=k){
    for(int i=0;i<k;i++)
      g=v.at(g);
    cout<<g+1<<endl;
  }
  else{
    for(int i=0;i<n;i++)
      g=v.at(g);
    h=g;
    while(h!=v.at(g)){
      g=v.at(g);
      c++;
    }
    c=(k-n)%c;
    for(int i=0;i<=c;i++)
      g=v.at(g);
    cout<<g+1<<endl;
  }
}

Measured memory_bytes: 4060
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;

int T;
int mapp[15];

bool dfs(int index,int L,int R){


    if(index==10)return true;

    bool flag=false;

    if(L<mapp[index])   flag=(flag||dfs(index+1,mapp[index],R));
    if(R<mapp[index])   flag=(flag||dfs(index+1,L,mapp[index]));
    return flag;
}


int main(){
    cin>>T;
    while(T--){
        for(int i=0;i<10;i++){
            scanf("%d",&mapp[i]);
        }

        if(dfs(0,0,0)){
            cout<<"YES"<<endl;
        }else{
            cout<<"NO"<<endl;
        }
        memset(mapp,0,sizeof(mapp));
    }
    return 0;
}



Measured memory_bytes: 3184
#include <bits/stdc++.h>
#define INF 1000000
#define watch(x) cout << setw(10) << "[" << (#x) << ":] " << (x) 
#define FORE(i,v,n) for(int i=v;i<n;i++)
#define FORI(i,v,n) for(int i=v;i<=n;i++)
       
using namespace std;

int const MOD = 1000000007;

int test_case(){
    string s;
    cin >> s;
    string answer = "Yes";
    if(s[2] == s[3] && s[4] == s[5]) answer = "Yes";
    else answer = "No";
    cout << answer << endl;            
	return 0;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int test=1;
	//cin >> test;
	for(int i=0;i<test;i++){
		//cout << "Case " << i << endl;
		test_case();
	}
	return 0;
}



Measured memory_bytes: 256
#Union Find union find

#Root: -1
#child: Parent's ID(non-negative)

class UnionFind():
    def __init__(self, N):
        self._root = [-1 for _ in range(N)]

    def find(self, x):
        if self._root[x] < 0: return x
        self._root[x] = self.find(self._root[x])
        return self._root[x]

    def unite(self, x, y):
        gx = self.find(x)
        gy = self.find(y)
        if gx == gy:
            return False
        if self._root[gx] > self._root[gy]:
            gx, gy = gy, gx
        self._root[gx] += self._root[gy]
        self._root[gy] = gx
        return True

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -(self._root[self.find(x)])


n, m, k = map(int, input().split())
uf = UnionFind(n)
cnt = [0] * (n+1)

for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    cnt[a] += 1
    cnt[b] += 1
    uf.unite(a, b)

for _ in range(k):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if uf.same(a, b) == True:
      cnt[a] += 1
      cnt[b] += 1

for i in range(n):
    ans = (uf.size(i) - 1) - cnt[i]
    print(ans, end=" ")

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

int main(void)
{   int n;
    long long int f =1e9+7;
    cin>>n;
    vector<long long int> shihao;
    for(int i=0;i<n;i++)
    {
        long long int h;
        cin>>h;
        shihao.push_back(h);
    }
    vector<long long int> sum;
    long long int sum1=0;
    for(int i=1;i<n;i++)
    {
        sum1=sum1+shihao[shihao.size()-i];
        sum.push_back(sum1%f);
    }
    long long int sum2=0;
    for(int i=0;i<n-1;i++)
    {
        sum2=(sum2+(shihao[i]*sum[n-1-i-1])%f)%f;
    }

    cout<<sum2%f;
    return 0;
}



Measured memory_bytes: 7912
n = int(input())
A=list(map(int,input().split()))
cnt=0
B=[]
C=[]
for i,a in enumerate(A):
    B.append(A[i]+i)
    C.append(A[i]-i)
from collections import Counter
Bd=dict(Counter(B))
Cd=dict(Counter(C))
cnt=0
for k in Bd.keys():
    b=Bd.get(k)
    c=Cd.get(-k)
    if b and c:
        cnt+=b*c
print(cnt)


Measured memory_bytes: 171088
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define eb emplace_back
#define f first
#define s second
#define sz(x) (ll)x.size()
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> osSet;

using pll = pair<ll, ll>;

const ll maxN = 1e7;
const ll INF = 1e17;
const ll MOD = 1e9 + 7;

ll xs[] = {-1, 1, 0, 0, -1, 1, 1, -1};
ll ys[] = {0, 0, -1, 1, -1, 1, -1, 1};

ll segtree[maxN << 2];
ll lazy[maxN << 2];
ll A[maxN];

inline ll left(ll x){
	return x << 1;
}

inline ll right(ll x){
	return (x<<1) + 1;
}

ll func(ll x){
	return (x*(x+1))/2;
}

ll _pow(ll b, ll p){
	if(p == 0) return 1;
	if(p == 1) return b;
	ll exB = b*b;
	if(p&1) return b*_pow(exB, p/2);
	return _pow(exB, p/2);
}

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll a, b;
	cin >> a >> b;
	cout << abs(b-func(b-a));
	return 0;
}

Measured memory_bytes: 3648
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>

using namespace std;

typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll x,t;
    cin>>x>>t;
    if(x-t>0) cout<<x-t;
    else cout<<0;
    cout<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

class B {
private:
	
	std::string S, T;
	
	void Input() {
		std::cin >> T;
		std::cin >> S;
	}
	
	int CountDifferent(std::string A, std::string B) {
		int DifferentNum = 0;
		if (A.size() != B.size()) return A.size();
		for (int i = 0; i < A.size(); i++) {
			if (A[i] != B[i]) DifferentNum++;
		}
		return DifferentNum;
	}
	
	int Check() {
		int Min = S.size();
		for (int i = 0; i < T.size() + 1 - S.size(); i++) {
			int DifferentNum = CountDifferent(T.substr(i, S.size()), S);
			if (DifferentNum < Min) Min = DifferentNum;
		}
		return Min;
	}
	
	void Output(int n) {
		std::cout << n << std::endl;
	}
	
public:
	
	B() {
		Input();
		Output(Check());
	}
	
};

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


Measured memory_bytes: 3616
#include<iostream>
using namespace std;
//一点更新区間取得
#include<vector>
#include<functional>
#include<limits>
template<typename T>
struct segtree{
	function<T(T,T)>calcfn,updatefn;
	int n;
	T defvalue;
	vector<T>dat;
	segtree(int n_=0,T defvalue_=numeric_limits<T>::max(),
		function<T(T,T)>calcfn_=[](T a,T b){return a<b?a:b;},
		function<T(T,T)>updatefn_=[](T a,T b){return b;}
	):defvalue(defvalue_),calcfn(calcfn_),updatefn(updatefn_)
	{
		n=1;
		while(n<n_)n<<=1;
		dat.assign(2*n-1,defvalue);
	}
	void copy(vector<T>v)
	{
		for(int i=0;i<v.size();i++)dat[i+n-1]=v[i];
		for(int i=n-2;i>=0;i--)dat[i]=calcfn(dat[i*2+1],dat[i*2+2]);
	}
	void update(int i,T a)
	{
		i+=n-1;
		dat[i]=updatefn(dat[i],a);
		while(i>0)
		{
			i=(i-1)/2;
			dat[i]=calcfn(dat[2*i+1],dat[2*i+2]);
		}
	}
	T query(int a,int b,int i=0,int l=0,int r=-1)//[a,b)
	{
		if(r<0)r=n;
		if(r<=a||b<=l)return defvalue;
		else if(a<=l&&r<=b)return dat[i];
		else
		{
			return calcfn(
				query(a,b,i*2+1,l,(l+r)/2),
				query(a,b,i*2+2,(l+r)/2,r)
			);
		}
	}
};

main()
{
	int n,q;cin>>n>>q;
	segtree<int>rmq(n);
	for(int i=0;i<q;i++)
	{
		int c,x,y;cin>>c>>x>>y;
		if(c)cout<<rmq.query(x,y+1)<<endl;
		else rmq.update(x,y);
	}
}



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

int main() {
	int N;
	bool flag=0;

	cin >> N;

	for (int i = N%4;i <= N; i+=4) {
		if (i % 7 == 0) flag = 1;
	}

	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rfor(i, a, b) for(int i = a; i < (int)b; i++)
#define all(ary) (ary).begin(), (ary).end()
#define debug(x) cerr << #x << ": " << x << '\n'
const int INF = 100100100;
const int MOD = 1000000007;
using namespace std;
using vec = vector<int>;
using ll = long long;
template <class T = int> T in(){ T x; cin >> x; return (x);}
const int dy[4] = {-1, 0, 0, 1};
const int dx[4] = {0, -1, 1, 0};

int x;

int main(int argc, char *argv[]){
    cin >> x;
    int res = 0;
    while((res * (res + 1)) / 2 < x) res++;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vectors<decltype(inner)>(x, inner); }
using ll = long long;
using ld =long double;
#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
int W,H;
bool inrange(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define MP make_pair
signed main(){
    int n; cin >> n;
    vector<int>v(n); rep(i,n) cin >> v[i];
    vector<int>hoge = v;
    sort(all(v));
    rep(i,v.size()){
        if(hoge[i]<=v[n/2-1])cout << v[n/2]<<endl;
        else cout << v[n/2-1]<<endl;
    }
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    int a,b,t;cin>>a>>b>>t;
    cout<<t/a*b<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(S: int):
    prev = S[0]
    for i in range(1,len(S)):
        if prev == S[i]:
            print("Bad")
            exit()
            break
        else:
            prev = S[i]
    print("Good")
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: int
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int N=(1<<18);
const int mod=1e9+7;
int dp[50][N];
int n,a,b,c;
int main()
{
	//freopen("H:\\c++1\\in.txt","r",stdin);
	//freopen("H:\\c++1\\out.txt","w",stdout);
	scanf("%d",&n);
	scanf("%d",&a);scanf("%d",&b);scanf("%d",&c);
	int bz=(1<<(a-1))|(1<<(a+b-1))|(1<<(a+b+c-1));
	int mx=(1<<(a+b+c));
	dp[0][0]=1;
	int p=1;
	for(int i=1;i<=n;i++){
		p=(1ll*10*p)%mod;
		for(int j=0;j<mx;j++){
			if(dp[i-1][j]==0)continue;
			for(int k=1;k<=10;k++){
				int now=(j<<k)|(1<<(k-1));
				now&=(mx-1);
				if((now&bz)!=bz){
					dp[i][now]=(dp[i][now]+dp[i-1][j])%mod;
				}
			}
		}	
	}
	int ans=p;
	for(int i=0;i<mx;i++){
		ans=(ans-dp[n][i]+mod)%mod;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 41216
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
const ll mod=2;
ll num2(ll n){
  ll res=0;
  for(ll i=2;i<=n;i*=2){
    res+=n/i;
  }
  return res;
}
bool nCr(ll n,ll r){
  return num2(n)-num2(r)-num2(n-r)<=0;
}
int main(){
  ll cnt0=0,cnt1=0,cnt2=0,n;
  cin>>n;
  vector<ll> vec;
  for(int i=0;i<n;i++){
    char c;
    cin>>c;
    int a=(int)(c-'0');
    a--;
    vec.push_back(a);
    if(a==0) cnt0++;
    else if(a==1) cnt1++;
    else cnt2++;
  }
  bool two_z=false;
//  cout<<cnt0<<" "<<cnt1<<" "<<cnt2<<endl;
  if(cnt1>0){
    for(int i=0;i<vec.size();i++) vec[i]%=2;
  }
  else if(cnt2>0){
    two_z=true;
    for(int i=0;i<vec.size();i++) vec[i]/=2;
  }
  ll ans=0;
  for(int i=0;i<n;i++) {
    if(nCr(n-1,i)){
      ans^=vec[i];
    }
  }
  cout<<(two_z?ans*2:ans)<<endl;
}


Measured memory_bytes: 10476
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;

bool is_prime(ll n) {
  for(ll i=2;i*i<=n;i++) {
    if(n%i==0) {
      return false;
    }
  }
  return n!=1;
}

int main() {
  ll n;
  cin >> n;
  vector<ll> ans(n);
  ll temp=0;
  ll tempn=11;
  while(1) {
    if(is_prime(tempn)) {
      ans[temp]=tempn;
      temp++;
    }
    tempn+=5;
    if(temp==n) {
      break;
    }
  }
  for(ll i=0;i<n;i++) {
    if(i!=0) {
      cout << " ";
    }
    cout << ans[i];
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define tezi ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
typedef long long ll;

int main(){
    tezi;
    ll n, ans = 0;
    cin >> n;
    vector<int> a(n + 1);
    for(int i = 1; i <= n; ++i){
        cin >> a[i];
    }
    map<int, int> v;
    for(int i = 1; i <= n; ++i){
        if(v.find(i - a[i]) != v.end()) ans += v[i - a[i]];
        v[i + a[i]]++;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 13496
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int INF = 1e8;

int main(){
	int N, M; cin >> N >> M;
	string S; cin >> S;
	int dp[N+1];
	dp[N] = 0;
	int ri[N+1];
	for(int i=M; i>=1; i--){
		if(S[i] == '0'){ ri[0] = i; break; }
		if(i==1){
			cout << -1 << endl;
			return 0;
		}
	}
	for(int i=1; i<N; i++){
		if(S[min(i+M, N)] == '0') ri[i] = min(i+M, N) - i;
		else{
			ri[i] = ri[i-1] - 1;
			if(ri[i] == 0){
				ri[i] = -1;
			}
		}
		if(ri[i] == -1){
			cout << -1 << endl;
			return 0;
		}
	}
	for(int i=N-1; i>=0; i--){
		if(S[i] == '0'){
			dp[i] = dp[i+ri[i]] + 1;
		}else{
			dp[i] = INF;
		}
	}
	int now = 0;
	int sma = dp[0];
	for(int i=0; i<dp[0]; i++){
		int cn = now;
		while(sma - i - 1 != dp[now]){
			now++;
		}
		cout << now - cn << " ";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int a,s,d,f,g,h,i,j;
	scanf("%d %d",&a,&s);
	if(a==4||a==6||a==9||a==11){
		if(s==4||s==6||s==9||s==11) printf("Yes\n");
		else printf("No\n");
	}
	else if(a==1||a==3||a==5||a==7||a==8||a==10||a==12){
		if(s==1||s==3||s==5||s==7||s==8||s==10||s==12) printf("Yes\n");
		else printf("No\n");
	}
	else if(a==2&&s==2) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include<algorithm> 
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cstdio>
#include<ctime>

using namespace std;

const int maxn=15;
int n,a[maxn];

inline int read() {
	int res=0,fh=1;
	char ch=getchar();
	while((ch>'9'||ch<'0')&&ch!='-')ch=getchar();
	if(ch=='-')fh=-1,ch=getchar();
	while(ch>='0'&&ch<='9')res=res*10+ch-'0',ch=getchar();
	return fh*res;
}

int main()
{
	int a=read(),b=read(),c=read();
	int d=a-b;
	if(c>d) printf("%d\n",c-d);
	else puts("0");
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int t = 1;
        Solver s = new Solver();
        for (int i = 1; i <= t; i++) {
            s.solve(i, in, out);
        }
        out.close();
    }

}

class Solver {

    void solve(int test, InputReader in, PrintWriter out) throws IOException {
        int n = in.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        for (int i = 0; i < n; i++) a[i] = in.nextInt();
        for (int i = 0; i < n; i++) b[i] = in.nextInt();
        int[] pre1 = new int[n];
        int[] pre2 = new int[n];
        pre1[0] = a[0];
        pre2[0] = b[0];
        for (int i = 1; i < n; i++) {
            pre1[i] = a[i] + pre1[i - 1];
            pre2[i] = b[i] + pre2[i - 1];
        }
        long ans = -1;
        for (int i = 0; i < n; i++) {
            long left = pre1[i];
            long right = pre2[n - 1] - (i > 0 ? pre2[i - 1] : 0);
            ans = Math.max(left + right, ans);
        }
        out.println(ans);
    }
}

class InputReader {
    BufferedReader br;
    StringTokenizer st;

    public InputReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
        st = null;
    }

    public String next() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return st.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public String nextLine() throws IOException {
        return br.readLine();
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 21460
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;


public class Main {
	public static void main(String[] args){
		//それぞれの患者の番号 p
		//1回目に歩いた距離 d1
		//2回目に歩いた距離 d2

		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();//患者の数 n
			int maxWalk = 0;//一番歩いた人の距離
			if(n==0){
				break;
			}
			Map<Integer, Integer> walkSum = new HashMap<Integer, Integer>();
			for(int i=0;i<n;i++){
				int p = sc.nextInt();
				int d1 = sc.nextInt();
				int d2 = sc.nextInt();
				int sumWalk = d1 + d2;
				if(sumWalk > maxWalk)maxWalk = sumWalk;
				walkSum.put(sumWalk,p);
			}
			System.out.println(walkSum.get((Object)maxWalk)+" "+maxWalk);
		}
	}
}

Measured memory_bytes: 16000
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<long long> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    sort(A.begin(), A.end());
    deque<long long> dq, dq2;
    dq.push_back(A[0]);
    int i = 1;
    int ind = N - 1;
    int j = 0;
    while(i <= ind){
        if(j % 2 == 0){
            if(ind - i == 0){
                if(abs(A[ind] - dq.front()) > abs(A[ind] - dq.back())) dq.push_front(A[ind]);
                else dq.push_back(A[ind]);
                ind--;
            }
            else{
                dq.push_back(A[ind]);
                ind--;
                dq.push_front(A[ind]);
                ind--;
            }
        }
        else{
            if(ind - i == 0){
                if(abs(A[i] - dq.front()) > abs(A[i] - dq.back())) dq.push_front(A[i]);
                else dq.push_back(A[i]); 
                i++;
            }
            else{
                dq.push_back(A[i]);
                i++;
                dq.push_front(A[i]);
                i++;
            }
        }
        j++;
    }
    dq2.push_back(A[N - 1]);
    i = 0;
    ind = N - 2;
    j = 1;
    while(i <= ind){
        if(j % 2 == 0){
            if(ind - i == 0){
                if(abs(A[ind] - dq2.front()) > abs(A[ind] - dq2.back())) dq2.push_front(A[ind]);
                else dq2.push_back(A[ind]);
                ind--;
            }
            else{
                dq2.push_back(A[ind]);
                ind--;
                dq2.push_front(A[ind]);
                ind--;
            }
        }
        else{
            if(ind - i == 0){
                if(abs(A[i] - dq2.front()) > abs(A[i] - dq2.back())) dq2.push_front(A[i]);
                else dq2.push_back(A[i]); 
                i++;
            }
            else{
                dq2.push_back(A[i]);
                i++;
                dq2.push_front(A[i]);
                i++;
            }
        }
        j++;
    }
    long long ans = 0;
    long long temp = dq.front();
    dq.pop_front();
    while(!dq.empty()){
        long long res = dq.front();
        dq.pop_front();
        ans += abs(res - temp);
        temp = res;
    }
    temp = dq2.front();
    dq2.pop_front();
    long long ans2 =0;
    while(!dq2.empty()){
        long long res = dq2.front();
        dq2.pop_front();
        ans2 += abs(res - temp);
        temp = res;
    }
    cout << max(ans, ans2) << endl;
}

Measured memory_bytes: 2688
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] p = new int[N];
		int max = 0;
		int a = 0;
		for(int i=0; i<N; i++) {
			p[i] = sc.nextInt();
			if(p[i]>=max) {
				max = p[i];
			}
		}
		sc.close();
		for(int i=0; i<N; i++) {
			a += p[i];
		}
		a -= max/2;
		System.out.println(a);
	}

}


Measured memory_bytes: 35840
import math
import sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from functools import lru_cache, reduce
from heapq import heapify, heappop, heappush
from itertools import chain, combinations, permutations, product
from typing import List, Dict

# import numpy as np

sys.setrecursionlimit(10**5 + 1)
input = sys.stdin.readline
write = sys.stdout.write


def read_item(cls=int):
    return cls(input())


def read_n_item(cls=int) -> list:
    return [cls(s) for s in input().split()]


def list2d(row, col, init_val=0) -> List[list]:
    return [[init_val] * col for _ in range(row)]


MOD = 10**9 + 7
# MOD = 998244353


N, M, Q = read_n_item()
items = []
for _ in range(Q):
    items.append(read_n_item())


def calc(cur, items):
    ans = 0
    for a, b, c, d in items:
        if cur[b-1] - cur[a-1] == c:
            ans += d
    return ans


def dfs(cur, pre):
    # print(cur, pre)
    if len(cur) == N:
        return calc(cur, items)
    ans = 0
    for i in range(pre, M+1):
        cur.append(i)
        ans = max(ans, dfs(cur, i))
        cur.pop()
    return ans


print(dfs([], 1))



Measured memory_bytes: 10324
card_n = int(input())
card_collection = list(map(int, input().split()))

scores = {"alice" : 0, "bob" :0}
card_collection.sort(reverse = True)
for i, card in enumerate(card_collection):
    if i % 2 == 0:
        scores['alice'] += card
    else:
        scores['bob'] += card
print(scores["alice"] - scores["bob"])

    

Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        String s = sc.next();
        int ans = 0;
        for(int i = 0; i < 1000; i++){
            String c100 = String.valueOf(i/100);
            String c10 = String.valueOf((i%100)/10);
            String c1 = String.valueOf(i%10);
            int a = s.indexOf(c100);
            if(a == -1) continue;
            int b = s.indexOf(c10,a+1);
            if(b == -1) continue;
            int c = s.indexOf(c1,b+1);
            if(c == -1) continue;
            ans++;
        }
        System.out.println(ans);
    }
    
}


Measured memory_bytes: 23764
#include <iostream>
#include <map>
#include <string>
using namespace std;

const int mod=int(1e9)+7;

int main(){
  map<char, int>m;
  int n;
  string s;
  cin >> n >> s;
  long ret=1;
  for(int i=0; i<n; i++)m[s[i]]++;
  for(pair<char, int>p:m){
    ret*=p.second+1;
    ret%=mod;
  }
  ret--;
  ret=(ret+mod)%mod;
  cout << ret;
  return 0;
}

Measured memory_bytes: 512
N = int(input())
b = list(map(int,input().split()))
a = [0]*(N)
a[0] = b[0]
a[N-1] = b[N-2]
for i in range(N-2):
  a[i+1] = min(b[i],b[i+1])
  
print(sum(a))

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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

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

    int n; cin >> n;
    vi a(n), b(n); REP(i,n) cin >> a[i];
    REP(i, n) b[i] = a[i] - (i + 1);    // i に依存する部分をまとめ上げる

    sort(b.begin(), b.end());
    int B = b[n/2];

    // マンハッタン距離を最小化するには，中央値を用いる．典型．

    ll ans = 0;
    REP(i, n) {
        ans += abs(a[i] - (B + i + 1));
    }
    cout << ans << endl;


    return 0;
}

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

const int INF = 1 << 29;

struct state {
    int dist;
    int tx, ty, kx, ky;
    state() {}
    state(int a, int b, int c, int d, int e): dist(a), tx(b), ty(c), kx(d), ky(e) {}
};

const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int W, H, tx, ty, kx, ky;
int wall[50][50];

int memo[50][50][50][50];
int& get_memo(state st) {
    return memo[st.tx][st.ty][st.kx][st.ky];
}

state next_state(state st, int d) {
    int ntx = st.tx+dx[d], nty = st.ty+dy[d];
    if (0 <= ntx && ntx < H && 0 <= nty && nty < W &&
            wall[ntx][nty] == 0) {
        st.tx = ntx; st.ty = nty;
    }
    int nkx = st.kx+dx[(d+2)%4], nky = st.ky+dy[(d+2)%4];
    if (0 <= nkx && nkx < H && 0 <= nky && nky < W &&
            wall[nkx][nky] == 0) {
        st.kx = nkx; st.ky = nky;
    }
    st.dist += 1;
    return st;
}


int main() {
    while (true) {
        cin >> W >> H;
        if (W == 0 && H == 0) break;
        cin >> ty >> tx >> ky >> kx;
        --tx; --ty; --kx; --ky;
        for (int j = 0; j < H; ++j) {
            for (int k = 0; k < W; ++k) {
                cin >> wall[j][k];
            }
        }

        queue<state> que;
        que.emplace(0, tx, ty, kx, ky);

        for (int j = 0; j < H; ++j) {
            for (int k = 0; k < W; ++k) {
                for (int l = 0; l < H; ++l) {
                    fill(memo[j][k][l], memo[j][k][l]+W, INF);
                }
            }
        }
        memo[tx][ty][kx][ky] = 0;

        int ans = 101;

        while (!que.empty()) {
            state st = que.front(); que.pop();

            if (st.dist > 100) {
                break;
            }

            if (st.tx == st.kx && st.ty == st.ky) {
                ans = st.dist;
                break;
            }

            for (int d = 0; d < 4; ++d) {
                state nst = next_state(st, d);

                if (nst.dist < get_memo(nst)) {
                    get_memo(nst) = nst.dist;
                    que.emplace(nst);
                }
            }
        }

        if (ans > 100) {
            cout << "NA" << endl;
        } else {
            cout << ans << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 27704
import java.util.*;
import java.io.*;

public class Main
{
	public static void main(String[] args)
	{
		FastScanner sc = new FastScanner();

		int n = sc.nextInt();

		List<Pair> list = new ArrayList<Pair>(n);
		for(int i = 0 ; i < n ; i++){
			int x = sc.nextInt();
			int l = sc.nextInt();

			list.add(new Pair(x-l, x+l));
		}

		Collections.sort(list, (p1,p2) -> { return  p1.first-p2.first;} );

		int max = 1;
		int last = list.get(0).last;
		for(int i = 1 ; i < n ; i++){
			if(list.get(i).first >= last){
				max++;
				last = list.get(i).last;
			}else{
				if(list.get(i).last < last){
					last = list.get(i).last;
				}
			}
		}

		System.out.println(max);

	}

}

class Pair{
	int first;
	int last;

	Pair(int f, int l){
		first = f;
		last = l;
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 30324
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<queue>
#define maxn 100005
#define mid ((nl+nr)>>1)
using namespace std;
typedef long long ll;
int n,m,tot=1;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(b*c>=a)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
}

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

int main(void) {
  long long A;
  char B[4];
  scanf("%lld%s", &A, B);
  long long C = (B[0]-'0')*100+(B[2]-'0')*10+(B[3]-'0');
  long long ans = A * C;
  ans /= 100;
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 1728
#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<map>

using namespace std;

#define rep(i,N) for(int i=0;i<N;i++) //0から


typedef long long ll;




ll binary_search(vector<ll> a, ll n, ll key){
    ll right = n, left = -1;
    ll md = (right + left) / 2;

    while(right - left > 1){
        if(a[md] <= key){
            right = md;
        }else{
            left = md;
        }
        md = (right + left) / 2;
    }
    if(left == -1) return -1; //無い場合
    return right;
}

vector<ll> prime;
void Prime(ll n){ //線形篩,素数列挙
    vector<ll> p(n,0);
    p[0]=1;
    p[1]=1;
    for(ll i=2;i<n;i++){
        if(p[i]==0){
            prime.push_back(i);
            p[i]=i;
        }
        ll k=prime.size();
        for(ll j=0;j<k && i*prime[j]<n && prime[j]<=p[i];j++){
            p[i*prime[j]]=prime[j];
        }
    }
}

#define MOD ((ll)1e+9 + 7)




//cout<<fixed<<setprecision(10);
int main(){
    int n,m;
    cin>>n>>m;
    vector<int> k(m),p(m);
    int s[10][10];
    rep(i,m){
        cin>>k[i];
        rep(j,k[i]){
            cin>>s[i][j];
            s[i][j]--;
        }
    }
    rep(i,m){
        cin>>p[i];
    }
    vector<int> cnt(m); //各組合せで条件k_j個のうちいくつがonか
    int ans=0;
    for(int bit=0; bit<(1<<n);bit++){
        rep(i,m){
            cnt[i]=0;
            rep(j,k[i]){
                if(bit & (1<<s[i][j])) cnt[i]++;
            }
        }
        int cnt2=0; //カウント値の偶奇が一致する数
        rep(i,m){
            if(cnt[i]%2==p[i]) cnt2++;
        }
        if(cnt2==m) ans++;
        //cout<<cnt2<<endl;
    }

    cout<<ans<<endl;

    return 0;
}



Measured memory_bytes: 3576
#include <stdio.h>
#include<math.h>

int main()
{
    double n, x, t, ans, r;
    scanf("%lf%lf%lf", &n, &x, &t);

    ans = (n*t)/x;
    r = ceil(ans/t);
    printf("%.0lf\n", r*t);
    return 0;
}


Measured memory_bytes: 3264
N = int(input())
D = [input().split() for l in range(N)]

zoro = []
for i in range(N):
  if D[i][0] == D[i][1]:
    zoro.append(1)
  else:
    zoro.append(0)

cnt = []
for i in range(N-2):
  cnt.append(zoro[i]+zoro[i+1]+zoro[i+2])
  

zoro_cnt = 0
for i in range(N-2):
  if cnt[i] == 3:
    zoro_cnt += 1


if zoro_cnt >= 1:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9196
#include <bits/stdc++.h>
#define sort stable_sort 
using namespace std; 

int _; 

int n,k,a[200050]; 
 
int main()
{
	//for(scanf("%d",&_);_;_--)
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++)
		scanf("%d",a+i);
	for(int i=0;i<n-k;i++)
	{
		if(a[i]<a[i+k])
			printf("Yes\n");
		else
			printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 4540
#include <iostream>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    int A[n][m];
    for(int i=0;i<n;i++){
        for(int u=0;u<m;u++){
            cin>>A[i][u];
        }
    }
    int b[m];
    for(int t=0;t<m;t++){
        cin>>b[t];
    }
     int c[n]={0};
    for(int g=0;g<n;g++){
        for(int s=0;s<m;s++){
            c[g]+=A[g][s]*b[s];
        }
        cout<<c[g]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3116
from collections import deque
n, m, *AB = map(int, open(0).read().split())
graph = [[] for _ in range(n)]
for a, b in zip(AB[::2], AB[1::2]):
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

d = [0] * n
queue = deque([0])
while queue:
    current_node = queue.popleft()
    for next_node in graph[current_node]:
        if d[next_node] == 0:
            d[next_node] = current_node+1
            queue.append(next_node)
print('Yes')
print(*d[1:], sep='\n')

Measured memory_bytes: 56828
from collections import Counter
n=int(input())
ans=[]
tt=0
for i in range(n):
    s=list(input())
    s.sort()
    s="".join(s)
    ans.append(s)
l=Counter(ans)
c=l.most_common()
for i,j in c:
    tt+=j*(j-1)//2
print(tt)

Measured memory_bytes: 114624
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#define INF 1e9
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  return s;
}

template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
  s << vv[i] << endl;
  }
  return s;
}


 
int N;
template<class T>
long long inversion(vector<T> &a) {
  int n = a.size();
  if (n <= 1)return 0;
  ll cnt = 0;
  vector<T> b(a.begin(), a.begin() + n / 2);
  vector<T> c(a.begin() + n / 2, a.end());
 
  cnt += inversion(b);
  cnt += inversion(c);
 
  int ai = 0, bi = 0, ci = 0;
 
  while (ai < n) {
    if (bi < b.size() && (ci == c.size() || b[bi] <= c[ci])) {
      a[ai] = b[bi];
      bi++;
    }
    else {
      cnt += n / 2 - bi;
      a[ai] = c[ci];
      ci++;
    }
    ai++;
  }
  return cnt;
}
 
long long count(vector<int> a, int k) {
    vector<int> b(N);
    vector<int> c(N + 1);
    vector<int> d(N + 1);
    rep(i, N) {
        if (a[i] <= k) b[i] = 1;
        else           b[i] = 0;
        c[i + 1] = c[i] + b[i];
        d[i + 1] = 2 * c[i + 1] - i;
    }
    c[0] = 0;
    d[0] = 0;
    repr(i, 1, N + 1){
        c[i] = c[i - 1] + b[i - 1];
        d[i] = 2 * c[i] - i;
    }
    reverse(all(d));
    return inversion(d);
}
 
 
int main(void) {
  cin >> N;
  vector<int> a(N);
  rep(i,N){
    cin >> a[i];
  }
 
  int ok = INF, ng = 0;
  while (ok - ng > 1) {
    int m = ng + (ok - ng) / 2;
    if (count(a, m) > (ll)N*(N + 1) / 4) {
      ok = m;
    }
    else {
      ng = m;
    }
  }
  cout << ok << endl;
}



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

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

int main() {
	string O, E;
	cin >> O >> E;

	int high = max(O.size(), E.size());
	int low = min(O.size(), E.size());

	string ans = "";
	for (int i = 0; i < high; ++i) {
		if (O.size() > E.size()) {
			ans += O[i];
			if (i < E.size()) {
				ans += E[i];
			}
		}
		else {
			if (i < O.size()) {
				ans += O[i];
			}
			ans += E[i];
			
		}
	}

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


Measured memory_bytes: 3500
#include <iostream>
#include <map>
#include <vector>
using namespace std;

int main(){
  map<int, int>m;
  int n;
  cin >> n;
  for(int i=0; i<n; i++){
    int a;
    cin >> a;
    m[a]++;
  }
  int ce=0;
  for(pair<int, int>p: m){
    m[p.first]%=2;
    if(m[p.first]==0){
      m[p.first]=2;
      ce++;
    }
  }
  if(ce%2==0)cout << m.size();
  else cout << m.size()-1;
  return 0;
}

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    int row = 0;
    bool res = false;
    rep(i, N){
        int a, b; cin >> a >> b;
        if(a == b) row++;
        else row = 0;
        if(row >= 3) res = true;
    }
    if(res) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
#define I INT32_MAX
#define IM INT_MIN
#define MOD 1000000007
// #define inti int
#define ll long long
#define lli long long int
#define rep(i,n) for (int i = 0; i < n; i++)
#define repk(i,k,n) for (int i = k; i <= n; i++)
#define repr(i,k,n) for (int i = k; i >= n; i--)
#define all(v) (v).begin(),(v).end()
typedef vector<int> vi;
typedef set<int> si;

void solve() {
	ll n, w;
	cin >> n >> w;
	ll dp[n + 2][w + 2];
	ll arr[n + 2];
	ll wt[n + 2];
	for (ll i = 0; i < n; ++i)
	{
		cin >> wt[i] >> arr[i];
	}

	// for (ll i = 0; i <= n; i++) {
	// 	dp[i][0] = 0;
	// }

	// for (ll i = 1; i <= w; ++i)
	// {
	// 	dp[0][i] = 0;
	// }

	for (ll i = 0; i <= n; ++i)
	{
		for (ll j = 0; j <= w; j++) {
			if (i == 0 or j == 0) {
				dp[i][j] = 0;
			}
			else if (wt[i - 1] > j) {
				dp[i][j] = dp[i - 1][j];
			}
			else {
				dp[i][j] = max(dp[i - 1][j] , arr[i - 1] + dp[i - 1][j - wt[i - 1]]);
			}
		}
	}
	cout << dp[n][w];
}

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

	int t = 1;
	// cin >> t;
	while (t--)
		solve();

}






Measured memory_bytes: 82472
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <iterator>
#include <string>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
int int_max = 2147483647;
int max_n = 1e5;
using mat2d_t = std::vector<std::vector<int64_t>>;

int main(int argc, char **argv) {
    int a, b, c;

    cin >> a >> b >> c;
    if (a == b && b == c)
        cout << "No";
    else if(a == b || b == c || a == c) {
        cout << "Yes";
    } else {
        cout << "No";
    }

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int a, b, c, d;
int l, r;

int main(){
	while(~scanf("%d %d %d %d", &a, &b,&c, &d)){
		l = a + b;
		r = c + d;
		if(l > r)
			printf("Left\n");
		else if(l < r)
			printf("Right\n");
		else
			printf("Balanced\n");
	}
}

Measured memory_bytes: 128
import math
a, b = list(input().split())
 
a = int(a)
f = [0, 0, 0]
f[0] = int(b[0])
f[1] = int(b[2])
f[2] = int(b[3])
 
x = (a*100*f[0] + a*10*f[1] + a*f[2])//100
print(x)

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

int main(){
	int n,a,b,c;
	int d[100];
	cin>>n>>a>>b>>c;
	for(int i=0;i<n;i++)cin>>d[i];
	sort(d,d+n,greater<int>());
	int ans=c/a;
	for(int i=0;i<n;i++){
		c+=d[i];
		a+=b;
		ans=max(ans,c/a);
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	int n, W;
	cin >> n >> W;
	long long w[n];
	int v[n];
	int sum = 0;
	for(int i = 0; i < n; ++i) {
		cin >> w[i] >> v[i];
		sum += v[i];
	}
	
	long long dp[2][100001];
	int ans = -1;
	for(int i = 1; i <= 100000; ++i) {
		dp[1][i] = LLONG_MAX/3;
	}
	dp[1][0] = 0;
	for(int i = 0; i < n; ++i) {
		int curr = i & 1;
		for(int j = 0; j <= sum; ++j) {
			dp[curr][j] = dp[curr ^ 1][j];
			if(j - v[i] >= 0) {
				dp[curr][j] = min(dp[curr][j], dp[curr ^ 1][j - v[i]] + w[i]);
			} 
			if(dp[curr][j] <= W) {
				ans = max(ans, j);
			}
		}
	}
	// assert(ans > 0);
	cout<<ans;
}

Measured memory_bytes: 5080
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pii pair<ll,ll>
#define tii tuple<ll,ll,ll>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define ld long double
#define mod 1000000007
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-9
//#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;   


int32_t main() 
{ 
    fastio
    string s, t;
    cin>>s>>t;
    int ans = 0;
    for(int i = 0; i<s.length(); ++i) {
        ans += s[i]!=t[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3804