akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>

struct tango{
    char word[32];
    int count,len;
};


int main(int argc, const char * argv[]) {
    int i=0,flag,j=0,maxcount=0,maxlen=0;
    char in[32];
    struct tango w[1000];
    
    while(scanf("%s",in)!=EOF){
        flag=0;
        for(i=0;i<=j;i++){
            if(strcmp(in,w[i].word)==0){
                w[i].count++;
                flag=1;
                break;
            }
        }
        
        if(flag==0){
            strcpy(w[j].word,in);
            w[j].len=(int)strlen(in);
            w[j].count=1;
            j++;
        }
    }
        for(i=0;i<=j;i++){
            if(w[maxcount].count<w[i].count)
                maxcount=i;
            if(w[maxlen].len<w[i].len)
                maxlen=i;
        }
    printf("%s %s\n",w[maxcount].word,w[maxlen].word);
    
    return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI=acos(-1);
const int INF = numeric_limits<int>::max();

int main(){
    int n;
    string s, t;
    cin >> n >> s >> t;

    rep(i,n) {
        cout << s[i] << t[i];
    }

    cout << endl;

    return 0;
    
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll W, H, x, y;
    cin >> W >> H >> x >> y;

    double S = H * W / 2.0;
    cout << setprecision(12) << S << endl;
    if(x*2==W && y*2==H) PR(1);
    else PR(0);

    return 0;
}

/*



*/

Measured memory_bytes: 3788
import java.util.*;
import java.lang.Math;
public class Main{
	public static int fact(int a) {
		int ret=1;
		for(int i=1;i<=a;++i)
			ret*=i;
		return ret;
	}
	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[][] ar=new int[n][2];
		
		for(int i=0;i<n;++i)
		{
			ar[i][0]=sc.nextInt();
			ar[i][1]=sc.nextInt();
		}
		double dist=0;
		for(int i=0;i<n;++i) {
			for(int j=i;j<n;++j) {
				dist+=Math.sqrt((ar[i][0]-ar[j][0])*(ar[i][0]-ar[j][0])+(ar[i][1]-ar[j][1])*(ar[i][1]-ar[j][1]));
			}
		}
		System.out.println(dist*2.0/n);
	}
}

Measured memory_bytes: 22868
N, Y = gets.chomp.split.map(&:to_i)

(0..N).each{|i|
    (0..N-i).each{|j|
        if 10000*i + 5000*j + 1000*(N-i-j) == Y then
            puts [i, j, N-i-j].join(" ")
            exit
        end
    }
}

puts "-1 -1 -1"

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

using namespace std;

#define pii pair<int,int>
#define ll long long
#define s second
#define f first



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


Measured memory_bytes: 256
#include<iostream>

using namespace std;

typedef long long ll;

ll a[100005];

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

  ll sum = 0;

  for(int i = 0; i < n; i++) {
    if(i & 1) sum -= a[i];
    else sum += a[i];
  }

  cout << sum <<' ';
  for(int i = 1; i < n; i++) {
    sum = 2 * a[i-1] - sum;
    if(i -1 == n) cout << sum << endl;
    else 
    cout << sum <<' ';
  }
}


Measured memory_bytes: 2048
n,k=map(int,input().split())
a=[0]+list(map(int,input().split()))
p=[]
for i in range(n):
	a[i+1]+=a[i]
for i in range(n+1):
	for j in range(i):
		p.append(a[i]-a[j])
p.sort(reverse=True)
ans=0
from math import log,ceil
r=ceil(log(sum(p))+10**-3)
for i in range(r+3,-1,-1):
	cnt=0
	for j in range(len(p)):
		if (ans+2**i)&p[j]==ans+2**i:
			cnt+=1
		if cnt==k:
			break
	if cnt==k:
		ans+=2**i
print(ans)

Measured memory_bytes: 112256
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
#define rep_re(i,n) FOR_RE(i,n,0)
//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a[4];
    cin >> n;
    int devisor;
    for(int i = 3; i >= 0; i--){
        devisor = pow(10, i);
        a[3 - i] = n / devisor;
        n %= devisor;
    }
    //rep(i, 4)   cout << a[i] << endl;
    char sign[4];
    sign[3] = '=';
    
    int count = 0;
    int result = a[0];
    bool flag = false;
    //これは全8パターンのループ
    for(int bit = 0; bit < (1 << 3); ++bit){
        //cout << count << endl;
        //count++;
        for(int i = 0; i < 3; ++i){
            if(bit & (1 << i)){
                sign[i] = '+';
            }
            else{
                sign[i] = '-';
            }
        }
        
        rep(i, 3){
            if(sign[i] == '+'){
                result += a[i + 1];
                sign[i] = '+';
            }else{
                result -= a[i + 1];
                sign[i] = '-';
            }
        }
        
        if(result == 7) flag = true;
        else    result = a[0];
        
        if(flag){
            rep(i, 4){
                cout << a[i] << sign[i];
            }
            cout << 7 << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
//	cut here before submit 
//	freopen ("testcase.blood", "r", stdin );

	int n;
	char dot;
	string type;
	map<string,int> sum; sum.clear();
	while (cin >> n >> dot >> type ){
		sum[type]++;
	} // end while
	cout << sum["A"] << endl;
	cout << sum["B"] << endl;
	cout << sum["AB"] << endl;
	cout << sum["O"] << endl;

	return 0;
}

Measured memory_bytes: 1212
package main

import "fmt"

func main() {
	var x, y int
	fmt.Scan(&x, &y)

	for i := 0; i <= x; i++ {
		if i*2+(x-i)*4 == y {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}


Measured memory_bytes: 1752
import System.IO (isEOF)

result :: Int -> [Int] -> [Int] -> [Int]
result 0 [] ans = ans
result 0 ws ans = ans
result w' [] ans = ans
result w' (w:ws) ans = if w' >= w
                         then result (w' - w) ws (w:ans)
                         else result w' ws ans

main = do done <- isEOF
          let ws = [512, 256, 128, 64, 32, 16, 8, 4, 2, 1]
          if done
            then return ()
            else do input <- getLine
                    let i = (read :: String -> Int) input
                    putStrLn $ unwords $ map show (result i ws [])
                    main

Measured memory_bytes: 3868
N = int(input()) 
 
count = 0
result = 'No'
for i in range(1, N+1):
    d1, d2 = map(int, input().split())
    if(d1 == d2):
        count += 1
    else:
        count = 0
    if(count == 3):
        result = 'Yes'
 
print(result)

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

using namespace std;

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

#define pb push_back
#define mp make_pair

int n, c, k;
int a[123456];
int ans = 0;
vector<int> bus;

int main()
{
    ios_base::sync_with_stdio(0);
    cin >> n >> c >> k;
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    for(int i = 0; i < n; i++){
        if(bus.empty()) bus.pb(a[i]);
        else{
            if(bus.size() == c){
                ans++;
                bus.clear();
                bus.pb(a[i]);
            }
            else if(a[i] - bus.front() > k){
                ans++;
                bus.clear();
                bus.pb(a[i]);
            }
            else{
                bus.pb(a[i]);
            }
        }
    }
    cout << ans + 1 << endl;
    return 0;
}


Measured memory_bytes: 892
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second) return a.second < b.second;
    else return a.first < b.first;
}
std::uint32_t euclidean_gcd(std::uint32_t a, std::uint32_t b){return b != 0 ? euclidean_gcd(b, a % b) : a;}


void solve(std::string S, std::string T, long long A, long long B, std::string U){
    if(U == S)cout<<A-1<<" "<<B<<endl;
    else if(U==T)cout<<A<<" "<<B-1<<endl;
    return;
}

int main(){
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    std::string U;
    std::cin >> U;
    solve(S, T, A, B, U);
    return 0;
}


Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var hw = Console.ReadLine().Split(' ');
        var h = int.Parse(hw[0]);
        var w = int.Parse(hw[1]);

        var s = new string[h];
        for (int i = 0; i < h; i++)
        {
            s[i] = Console.ReadLine();
        }

        Console.WriteLine(new string('#', w + 2));
        for (int i = 0; i < h; i++)
        {
            Console.Write("#");
            Console.Write(s[i]);
            Console.WriteLine("#");
        }
        Console.WriteLine(new string('#', w + 2));
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
#define int long long

const int LINF=1e18;

int dp[305][305][305];//dp[i][j][k]:列i+1までにj列を変更しi+1のhがm[k]の時の確定しているコストの最小値
template<typename T>
void chmax(T &a,T b){
  if(a<b)a=b;
}
template<typename T>
void chmin(T &a,T b){
  if(a>b)a=b;
}

signed main(){
  int n,K;cin>>n>>K;
  vector<int> h(n);
  for(int i=0;i<n;i++)cin>>h[i];
  map<int,int> m;
  for(int i=0;i<n;i++)m[h[i]]=0;
  m[0]=0;
  int cnt=0;
  for(auto &p:m)p.second=cnt++;
  int A=m.size();
  vector<int> re(A+5);
  for(auto p:m)re[p.second]=p.first;
  for(int i=0;i<305;i++)for(int j=0;j<305;j++)for(int k=0;k<305;k++)dp[i][j][k]=LINF;
  dp[0][0][0]=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<305;j++){
      for(int k=0;k<A;k++){
        chmin(dp[i+1][j][m[h[i]]],dp[i][j][k]+max(h[i]-re[k],0LL));
        chmin(dp[i+1][j+1][k],dp[i][j][k]);
      }
    }
  }
  int ans=LINF;
  for(int j=0;j<=K;j++)for(int k=0;k<305;k++)chmin(ans,dp[n][j][k]);
  cout<<ans<<endl;
}


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

#define MAX(X,Y) ((X)>(Y)?(X):(Y))

int main(void){
  int a, b, x;
  int ans;
  
  cin >> a >> b >> x;
  x = (x+499)/500;
  if (a>=2*b){
    ans = x*b;
  } else if (a>b){
    ans = x/2*a + x%2*b;
  } else {
    ans = (x+1)/2*a;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    std::string s;
    std::cin >> n >> s;
    for (auto c : s) {
        c = c + n;
        if (c > 'Z') c = c - 'Z' + 'A' - 1;
        std::cout << c;
    }
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 256
from collections import deque
K = int(input())



def ln():
    q = deque()
    m = 1
    nd = 1

    while True:
        for i in range(9):
            q.append(([i+1], 1))

            while q:
                n, d = q.popleft()
                if d == nd:
                    if m == K:
                        return n
                    m += 1
                    continue

                if n[-1] == 0:
                    q.append((n+[0], d+1))
                    q.append((n+[1], d+1))
                elif n[-1] == 9:
                    q.append((n+[8], d+1))
                    q.append((n+[9], d+1))
                else:
                    q.append((n+[n[-1]-1], d+1))
                    q.append((n+[n[-1]], d+1))
                    q.append((n+[n[-1]+1], d+1))

        nd+=1

print(''.join(map(str, ln())))

Measured memory_bytes: 7360
/**
**	author : Raghav
**	codechef:raghav_456
**	codeforces:raghavramola7
**/
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define deb(x)          cout<<#x<<" "<<x<<endl
#define ar 				array
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void Raghav()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int32_t main()
{
	Raghav();
	int n;
	string s;
	cin >> n >> s;
	int l = 0;
	int r = n - 1;
	int ans = 0;
	while (l < r) {
		while (l < n && s[l] == 'R') {
			++l;
		}
		while (r >= 0 && s[r] == 'W') {
			--r;
		}
		if (l < r) {
			swap(s[l], s[r]);
			++ans;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3664
h,w=map(int,input().split())
ans_x=0
ans_y=0
for i in range(h):
    s=list(input().split())
    for j in range(w):
        if s[j]=="snuke":
            ans_x=j+1
            ans_y=i+1
print(chr(96+ans_x).upper()+str(ans_y))

Measured memory_bytes: 3060
#pragma GCC optimize("O3")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
template<typename T>
using indexed_set = tree<T, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T>
using indexed_multiset = tree<T, null_type, less_equal<>, rb_tree_tag, tree_order_statistics_node_update>;
using ll = long long;

#define rep(i, a, b) for(int (i)=(a);(i)<(int)(b);++(i))
#define Rrep(i, a, b) for(int (i)=(a);(i)>=(int)(b);--(i))

#define EPS (1e-10)
#define equal(a, b) (fabs((a)-(b))<EPS)

#define LOG2(x) ((unsigned)(sizeof(unsigned long long) * 8 - __builtin_clzll((x)) - 1))
#define INF 0x3f3f3f3f

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

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

//const int N = 1 << 18;


class edge {
public:
    int from, to;
    ll cost;

    edge(int t, ll c) : from(-1), to(t), cost(c) {}

    edge(int f, int t, ll c) : from(f), to(t), cost(c) {}

    bool operator<(const edge &e) const {
        return cost < e.cost;
    }

    bool operator>(const edge &e) const {
        return cost > e.cost;
    }
};

const int N = 3010;
const ll inf = -(ll) 1e15;

vector<edge> g;
bool isInf[N];
ll d[N];
int n, m;

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

    cin >> n >> m;
    rep(i, 0, m) {
        int a, b, c;
        cin >> a >> b >> c;
        --a, --b;
        g.emplace_back(a, b, c);
    }
    fill(d, d + n, inf);
    d[0] = 0;
    rep(i, 0, n - 1) {
        for (edge &e : g) {
            if (d[e.from] == inf) continue;
            d[e.to] = max(d[e.to], d[e.from] + e.cost);
        }
    }
    rep(i, 0, n) {
        for (edge &e : g) {
            if (d[e.from] == inf) continue;
            if (d[e.to] < d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                isInf[e.to] = true;
            }
            if (isInf[e.from]) isInf[e.to] = true;
        }
    }
    if (isInf[n - 1]) cout << "inf" << endl;
    else cout << d[n - 1] << endl;
}

Measured memory_bytes: 384
/*
*
*	AUTHOR :- @soham01
*		// "WORK HARD AND NEVER GIVE UP" //
*
*/
#include "bits/stdc++.h"

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> //find_by_order(), order_of_key()
#define pb push_back
#define mp make_pair
#define vi vector<long long int >
#define vb vector<bool>
#define vs vector<string>
#define vd vector<double>
#define vvi vector<vector<long long int> >
#define vp vector<pair<long long int , long long int > >
#define seti set<long long int >
#define setc set<char>
#define setd set<double>
#define mod 1000000009
#define endl '\n'
typedef long long int lli;

// ITS MY REQUEST TO PLEASE PLEASE DO LOOK AT THE CONSTRAINS GIVEN CAREFULLY
// DO CHECK FOR CORNER CASES

/*-------LET THE GAME BEGIN-----------*/

void solve()
{
	lli n, i, j, c = 0, s = 0, f = 0,f1=0,f2=0;
	cin >> n;
	lli arr[n], brr[n];
	for (i = 0; i < n; i++)
	{
		cin >> arr[i];
	}
	for (i = 0; i < n; i++)
	{
		cin >> brr[i];
	}
	for(i=0;i<n;i++)
	{
		if(arr[i] == brr[i])
		{
			f1=1;
			break;
		}
	}
	if(f1==1){
	sort(brr, brr + n, greater<int>());
	for(i=0;i<n;i++)
	{
	if(arr[i] == brr[i])
		{
			f2=1;
			break;
		}	
	}
	if(f2 == 1){
	vi crr, drr;
	for (i = 0; i < n / 2; i++)
	{
		crr.pb(brr[i]);
	}
	for (i = n / 2; i < n; i++)
	{
		drr.pb(brr[i]);
	}
	sort(crr.begin(), crr.end());
	sort(drr.begin(), drr.end());
/*	for (i = 0; i < n / 2; i++)
	{
		cout << crr[i] << " ";
	}
	cout << endl;
	for (i = 0; i < drr.size(); i++)
	{
		cout << drr[i] << " " ;
	}
	cout << endl;
	*/
	for (i = 0; i < n / 2; i++)
	{
		brr[i] = crr[i];
	}
	if (n % 2 != 0) {
		for (i = 0; i < drr.size(); i++)
		{
			brr[i + n / 2] = drr[i];
		}
	}
	else {
		for (i = 0; i < n / 2; i++)
		{
			brr[i + n / 2] = drr[i];
		}
	}
	for (i = 0; i <= n / 2; i++)
	{
		if (brr[i] == arr[i])
		{
			swap(brr[i], brr[n - i - 1]);
		}
	}
	for (i = 0; i < n; i++)
	{
		if (arr[i] == brr[i])
		{
			f = 1;
			break;
		}
	}
/*	for (i = 0; i < n; i++)
	{
		cout << brr[i] << " ";
	}
	cout << endl;*/
	if (f)
	{
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
		for (i = 0; i < n; i++)
		{
			cout << brr[i] << " ";
		}
		cout << endl;
	}
	}
	else{
		cout << "Yes" << endl;
		for(i=0;i<n;i++)
		{
			cout << brr[i] << " ";
		}
		cout << endl;
	}
	}
	else {
		cout << "Yes" << endl;
		for(i=0;i<n;i++)
		{
			cout << brr[i] << " ";
		}
		cout << endl;
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	solve();
	return 0;
}


Measured memory_bytes: 8700
<?php
$n = trim(fgets(STDIN));
$ptTaro = 0;
$ptHanako = 0;

for ($i = 0; $i < $n; $i++) {
  list($text1, $text2) = explode(" ", trim(fgets(STDIN)));
  $cmp = strcmp($text1, $text2);
  if ($cmp == 0) {
    $ptTaro++;
    $ptHanako++;
  } elseif ($cmp > 0) {
    $ptTaro += 3;
  } else {
    $ptHanako += 3;
  }
}

echo "$ptTaro $ptHanako\n";



Measured memory_bytes: 9236
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fr first
#define sc second
#define N 300009
#define inf 2e16
#define pi pair<ll,ll>
#define pb push_back
using namespace std;
typedef long long ll;
ll a[509][509];
ll w,h;
struct info {
    ll a,b,c,d;
};
vector< info >ans;
int main()
{
    cin>>h>>w;
    for(ll i=1;i<=h;i++) for(ll j=1;j<=w;j++) cin>>a[i][j];
    for(ll i=1;i<=h;i++)
    {
        if(i%2==1)
        {
            for(ll j=1;j<=w;j++)
            {
                if(a[i][j]%2==1)
                {
                    info in;
                    in.a=i,in.b=j;
                    a[i][j]--;
                    if(j<w)
                    {
                        a[i][j+1]++;
                        in.c=i,in.d=j+1;
                        ans.push_back(in);
                    }
                    else 
                    {
                        if(i+1>h) continue;
                        a[i+1][j]++;
                        in.c=i+1,in.d=j;
                        ans.push_back(in);
                    }
                }
            }   
        }
        else
        {
            for(ll j=w;j>=1;j--)
            {
                if(a[i][j]%2==1)
                {
                    info in;
                    in.a=i,in.b=j;
                    a[i][j]--;
                    if(j>1)
                    {
                        a[i][j-1]++;
                        in.c=i,in.d=j-1;
                        ans.push_back(in);
                    }
                    else 
                    {
                        if(i+1>h) continue;
                        a[i+1][j]++;
                        in.c=i+1,in.d=j;
                        ans.push_back(in);
                    }
                }
            }
        }
    }
    ll sz=ans.size();
    cout<<sz<<endl;
    for(int i=0;i<sz;i++)
    {
        cout<<ans[i].a<<" "<<ans[i].b<<" "<<ans[i].c<<" "<<ans[i].d<<endl;
    }
    return 0;
}


Measured memory_bytes: 9344
import java.util.Scanner;
class Main{
    public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int a, b, sum;
		int digit = 1;
		while(in.hasNextInt()){
			a = in.nextInt();
			if(in.hasNextInt()){
				b = in.nextInt();
			}else{
				break;
			}
			sum = a+b;
			while(sum>=10){
				sum /= 10;
				digit++;
			}
			System.out.println(digit);
			digit = 1;
		}
    }
}

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

typedef long long ll;
const ll INF = 1LL<<60, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
#define m_p make_pair

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll a,b;
  cin >> a >> b;
  if(abs(a-b)%2==0){
    cout << a+(b-a)/2 << endl;
  }else{
    cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}

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

/*約数が75個
75=3*5*5
a^74,a^2*b^24,a^4*b^14,a^2*b^4*c^4
*/

int prime[25]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};

int main(){
  int n;
  cin >> n;
  int a[25];
  for(int i=0;i<25;i++) a[i]=0;
  for(int i=1;i<=n;i++){
    int x=i;
    for(int j=0;j<25;j++){
      while(x%prime[j]==0){
        x/=prime[j];
        a[j]++;
      }
    }
  }
  int ans=0;
  if(a[0]>=74){
    ans++;
  }
  for(int i=0;i<25;i++){
    for(int j=0;j<25;j++){
      if(i!=j&&a[i]>=2&&a[j]>=24){
        ans++;
      }
    }
  }
  for(int i=0;i<25;i++){
    for(int j=0;j<25;j++){
      if(i!=j&&a[i]>=4&&a[j]>=14){
        ans++;
      }
    }
  }
  int count=0;
  for(int i=0;i<25;i++){
    for(int j=0;j<25;j++){
      for(int k=0;k<25;k++){
        if(i!=j&&i!=k&&j!=k&&a[i]>=2&&a[j]>=4&&a[k]>=4){
          count++;
        }
      }
    }
  }
  cout << ans+count/2 << endl;
}

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

int main(void){
    long long n, k, ma=0, sum=0, a[100010];
    cin >> n >> k;
    for(long long i=0;i<n;++i){
        cin >> a[i];
    }
    for(int i=0;i<50;++i){
        long long b=1;
        b <<= i;
        if(k <= b){
            ma = i;
            break;
        }
    }
    long long ans = 0;
    for(int i=ma;i>=0;--i){
        long long tmp = 1;
        tmp <<= i;
        if((ans | tmp) > k){
            continue;
        }
        long long cnt=0;
        for(int j=0;j<n;++j){
            if((a[j]&tmp)!=0) ++cnt;
        }
        if(cnt <= n/2){
            ans |= tmp;
        }
    }
    for(int i=0;i<n;++i){
        sum += (a[i]^ans);
    }
    cout << sum << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

// fatorial.cpp depend on this.
#ifndef MOD_INT
#define MOD_INT
template<int mod>
struct ModInt{
	private:
		int x;

	public:
		ModInt() : x(0){}
		ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod){}
	
		ModInt &operator+=(const ModInt &p){
			if((x += p.x) >= mod) x -= mod;
			return *this;
		}
		ModInt &operator-=(const ModInt &p){
			if((x += mod - p.x) >= mod) x -= mod;
			return *this;
		}
		ModInt &operator*=(const ModInt &p){
			x = (int) (1LL * x * p.x % mod);
			return *this;
		}
		ModInt &operator/=(const ModInt &p){
			*this *= p.inverse();
			return *this;
		}
	
		ModInt operator-() const {return ModInt(-x);}
		ModInt operator+(const ModInt &p) const {return ModInt(*this) += p;}
		ModInt operator-(const ModInt &p) const {return ModInt(*this) -= p;}
		ModInt operator*(const ModInt &p) const {return ModInt(*this) *= p;}
		ModInt operator/(const ModInt &p) const {return ModInt(*this) /= p;}
		bool operator==(const ModInt &p) const {return x == p.x;}
		bool operator!=(const ModInt &p) const {return x != p.x;}
		bool operator<(const ModInt &p) const {return x < p.x;}
	
		template<typename T>
		operator T() const {return (T)x;}
	
		ModInt inverse() const {
			int a = x, b = mod, u = 1, v = 0, t;
			while(b > 0) {
				t = a / b;
				swap(a -= t * b, b);
				swap(u -= t * v, v);
			}
			return ModInt(u);
		}
	
		ModInt pow(int64_t n) const {
			ModInt ret(1), mul(x);
			while(n > 0) {
				if(n & 1) ret *= mul;
				mul *= mul;
				n >>= 1;
			}
			return ret;
		}
	
		friend ostream &operator<<(ostream &os, const ModInt &p){
			return os << p.x;
		}
	
		friend istream &operator>>(istream &is, ModInt &a){
			int64_t t;
			is >> t;
			a = ModInt< mod >(t);
			return (is);
		}
	
		static int get_mod(){return mod;}
};

using mint = ModInt<MOD>;
#endif

int main(void){
	int N, M;
	cin >> N >> M;
	vector<int> S(N), T(M);
	for(int i = 0; i < N; i++) cin >> S[i];
	for(int i = 0; i < M; i++) cin >> T[i];

	vector<vector<mint>> dp(N+1, vector<mint>(M+1, 0));
	for(int i = 0; i <= N; i++) dp[i][0] = 1;
	for(int i = 0; i <= M; i++) dp[0][i] = 1;

	for(int i = 0; i < N; i++){
		for(int j = 0; j < M; j++){
			dp[i+1][j+1] = dp[i+1][j] + dp[i][j+1] - dp[i][j];
			// if(S[i] == T[j]) dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] * 2);
			if(S[i] == T[j]) dp[i+1][j+1] += dp[i][j];
			// printf("dp[%d][%d] = %d\n", i+1, j+1, (int)dp[i+1][j+1]);
		}
	}

	cout << dp[N][M] << '\n';

	return 0;
}

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

void rle(const string& s, vector<pair<char, ll>>& out){
    out.clear();
    if(s.size() == 0){ return; }
    ll num = 1;
    for(ll i = 1; i < s.size(); ++i){
        if(s.at(i) != s.at(i - 1)){
            out.emplace_back(s.at(i - 1), num);
            num = 1;
        }else{
            num++;
        }
    }
    out.emplace_back(s.back(), num);
}


void solve(long long N, std::string S){
    vector<pair<char, ll>> x;
    rle(S, x);
    vector<ll> csb(x.size(), 0), csw(x.size(), 0);
    REP(i, x.size()){
        if(i > 0){
            csb.at(i) = csb.at(i - 1);
        }
        if(x.at(i).first == '#'){
            csb.at(i) += x.at(i).second;
        }
    }
    for(ll i = (ll)x.size() - 1; i >= 0; --i){
        if(i < (ll)x.size() - 1){
            csw.at(i) = csw.at(i + 1);
        }
        if(x.at(i).first == '.'){
            csw.at(i) += x.at(i).second;
        }
    }

    ll ans = min(csw.at(0), csb.back());
    for(ll i = 1; i < x.size(); ++i){
        ans = min(ans, csb.at(i - 1) + csw.at(i));
    }
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 7536
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<int>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  int n,k;
  cin >> n >> k;
  int a[n];
  rep(i,n)cin >> a[i];
  rep(i,n-k){
    if(a[i]<a[i+k])cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}


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

int main()
{
    ll n;
    cin >> n;
    if (n < 10)
    {
        cout << n << endl;
    }
    else if (n < 100)
    {
        cout << 9 << endl;
    }
    else if (n < 1000)
    {
        cout << 9 + (n - 99) << endl;
    }
    else if (n < 10000)
    {
        cout << 909 << endl;
    }
    else if (n < 100000)
    {
        cout << 909 + n - 9999 << endl;
    }
    else
    {
        cout << 90909 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N=int(input())
ans=[0]*(N+1)
for x in range(1,101):  
    for y in range(1,101):
        for z in range(1,101):
            fn=x**2+y**2+z**2+x*y+y*z+z*x
            if fn>N:
                break
            else:
                ans[fn]=ans[fn]+1
for n in range(1,N+1):
    print(ans[n])

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int n, t;
    cin >> n >> t;
    vector<int> d(n);
    int ans = 1e8;
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        if (t >= b) {
            ans = min(ans, a);
        }
    }
    if (ans == 1e8) {
        cout << "TLE" << endl;
    }
    else {
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <string> //C++
#include <iostream> //C++
#include <vector> //C++
#include <algorithm> //C++
#include <queue> //C++
using namespace std; //C++



int main(void) {
	
	int a[10];
	cin >> a[1] >> a[2] >> a[3] >> a[4]>> a[5];

	int i;
	for (i = 1; i <= 5; i++) {
		if (a[i] == 0) {
			cout << i;
			return 0;
		}
	}

}

Measured memory_bytes: 3580
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx")
//#undef LOCAL
#include <bits/stdc++.h>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

#ifdef LOCAL
struct PrettyOS {
    ostream& os;
    bool first;
    template <class T> auto operator<<(T&& x) {
        if (!first) os << ", ";
        first = false;
        os << x;
        return *this;
    }
};
template <class... T> void dbg0(T&&... t) {
    (PrettyOS{cerr, true} << ... << t);
}
#define dbg(...)                                            \
    do {                                                    \
        cerr << __LINE__ << " : " << #__VA_ARGS__ << " = "; \
        dbg0(__VA_ARGS__);                                  \
        cerr << endl;                                       \
    } while (false);
#else
#define dbg(...)
#endif

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    return os << "P(" << p.first << ", " << p.second << ")";
}

template <class T> ostream& operator<<(ostream& os, const V<T>& v) {
    os << "[";
    for (auto d : v) os << d << ", ";
    return os << "]";
}

struct UnionFind {
    V<int> p, r;
    int gn;
    UnionFind(int n = 0) : p(n, -1), r(n, 1), gn(n) {}
    void merge(int a, int b) {
        int x = group(a), y = group(b);
        if (x == y) return;  // same
        gn--;
        if (r[x] < r[y]) {
            p[x] = y;
        } else {
            p[y] = x;
            if (r[x] == r[y]) r[x]++;
        }
    }
    int group(int a) {
        if (p[a] == -1) return a;
        return p[a] = group(p[a]);
    }
    bool same(int a, int b) { return group(a) == group(b); }
};

void kmzk() {
    cout << "No" << endl;
    exit(0);
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n; ll m; int q;
    cin >> n >> m >> q;
    using P = pair<int, int>;
    auto uf = UnionFind(n);
    V<P> one;
    for (int i = 0; i < q; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        if (c == 0) {
            uf.merge(a, b);
        } else {
            one.push_back({a, b});
        }
    }
    for (auto p: one) {
        if (uf.same(p.first, p.second)) {
            kmzk();
        }
    }

    ll gn = uf.gn;
    if (one.size() && gn == 2) kmzk();
    dbg(gn, one.size());

    ll min_m = n - 1;
    if (one.size()) min_m++;
    ll max_m = n - gn + gn * (gn - 1) / 2;
    dbg(n, m, max_m);

    if (m < min_m || max_m < m) kmzk();

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


Measured memory_bytes: 2168
#include <iostream>
#include <cmath>
using namespace std;
const int INF = 1 << 30;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
int main() {
        int N; cin >> N;
        int dp[N+1][3];
        int h[3];
        bool af, bf, cf;

        for (auto i = 0; i <= N; ++i) for (auto j = 0; j < 3; ++j) dp[i][j] = 0;

        for (auto i = 1; i <= N; ++i) {
                cin >> h[0] >> h[1] >> h[2];
                for (auto j = 0; j < 3; ++j) {
                        for (auto k = 0; k < 3; ++k) {
                                if (j==k) continue;
                                dp[i][k] = max(dp[i][k], dp[i-1][j]+h[k]);
                        }
                }
        }
        cout << max(dp[N][0], max(dp[N][1], dp[N][2])) << "\n";
        return 0;
}


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

int main()
{
	int n, k, nn, i, j;
	double p = 0;
	scanf("%d %d", &n, &k);
	for (i = 1; i <= n; i++) {
		j = 0;
		nn = i;
		while (nn < k) {
			nn *= 2;
			j++;
		}
		p += pow(0.5, j) / (1.0 * n);
	}
	printf("%.10f\n", p);
	return 0;
}

Measured memory_bytes: 256
def modcmb(n,r,mod=10**9+7):
    res=1
    div=min(r,n-r)
    for i in range(div):
        res=res*(n-i)*pow(div-i,mod-2,mod)%mod
    return res%mod

n,a,b=[int(i) for i in input().split()]
mod=10**9+7
ans=pow(2,n,mod)-1
ans-=modcmb(n,a)
ans%=mod
ans-=modcmb(n,b)
ans%=mod
print(ans)

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

using lint = long long;

template <int MOD_>  struct modnum {
private:
	using lint = long long;
	lint v;
	static int modinv(int a, int m) {
		a %= m;
		assert(a);
		return a == 1 ? 1 : int(m - lint(modinv(m, a)) * lint(m) / a);
	}
public:
	static constexpr int MOD = MOD_;
	modnum() : v(0) {}
	modnum(lint v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
	explicit operator int() const { return v; }
	friend std::ostream &operator<<(std::ostream& out, const modnum& n) { return out << int(n); }
	friend std::istream &operator>>(std::istream& in, modnum& n) { lint v_; in >> v_; n = modnum(v_); return in; }
	friend bool operator==(const modnum& a, const modnum& b) { return a.v == b.v; }
	friend bool operator!=(const modnum& a, const modnum& b) { return a.v != b.v; }
	modnum inv() const {
		modnum res;
		res.v = modinv(v, MOD);
		return res;
	}
	modnum neg() const {
		modnum res;
		res.v = v ? MOD-v : 0;
		return res;
	}
	modnum operator-() const { return neg(); }
	modnum operator+() const { return modnum(*this); }
	modnum& operator+=(const modnum& o) {
		v += o.v;
		if (v >= MOD) v -= MOD;
		return *this;
	}
	modnum& operator-=(const modnum& o) {
		v -= o.v;
		if (v < 0) v += MOD;
		return *this;
	}
	modnum& operator*=(const modnum& o) {
		v = int(lint(v) * lint(o.v) % MOD);
		return *this;
	}
	modnum& operator/=(const modnum& o) { return *this *= o.inv(); }
	friend modnum operator+(const modnum& a, const modnum& b) { return modnum(a) += b; }
	friend modnum operator-(const modnum& a, const modnum& b) { return modnum(a) -= b; }
	friend modnum operator*(const modnum& a, const modnum& b) { return modnum(a) *= b; }
	friend modnum operator/(const modnum& a, const modnum& b) { return modnum(a) /= b; }
};
 
template <typename T> T pow(T a, lint b) {
	assert(b >= 0);
	T r = 1; while (b) { if (b & 1) r *= a; b >>= 1; a *= a; } return r;
}

using num = modnum<int(1e9)+7>;

num ncr(int n, int k) {
	num res = 1;
	for (int i = 1; i <= k; ++i) {
		res *= (n - i + 1);
		res /= i;
	}
	return res;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, a, b;
	cin >> n >> a >> b;
	num base = 2;
    num total = pow(base, n) - 1;
    num remove_a = ncr(n, a);
    num remove_b = ncr(n, b);
    cout << total - (remove_a + remove_b) << '\n';
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int main(){
	int i,j,a[100][100],b[100],n,m,sum;
	char input[5002],*p=NULL;
	
	fgets(input,sizeof input,stdin);
	sscanf(input,"%d %d",&n,&m);
	
	for(i=0;i<n;i++){
		fgets(input,sizeof input,stdin);
		p=strtok(input," ");
		a[i][0]=atoi(p);
		
		for(j=1;j<m;j++){
			p=strtok(NULL," ");
			a[i][j]=atoi(p);
		}
		
	}
	
	for(i=0;i<m;i++){
		fgets(input,sizeof input,stdin);
		sscanf(input,"%d",&b[i]);
	}
	
	for(i=0;i<n;i++){
		sum=0;
		for(j=0;j<m;j++){
			sum+=a[i][j]*b[j];
		}
		printf("%d\n",sum);
		
	}
	
	return 0;
}

Measured memory_bytes: 640
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0]*(n+1)

    def __iter__(self):
        psum = 0
        for i in range(self.size):
            csum = self.sum(i+1)
            yield csum - psum
            psum = csum
        raise StopIteration()

    def __str__(self):  # O(nlogn)
        return str(list(self))

    def sum(self, i):
        # [0, i) の要素の総和を返す
        if not (0 <= i <= self.size): raise ValueError("error!")
        s = 0
        while i>0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        if not (0 <= i < self.size): raise ValueError("error!")
        i += 1
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    def __getitem__(self, key):
        if not (0 <= key < self.size): raise IndexError("error!")
        return self.sum(key+1) - self.sum(key)

    def __setitem__(self, key, value):
        # 足し算と引き算にはaddを使うべき
        if not (0 <= key < self.size): raise IndexError("error!")
        self.add(key, value - self[key])

N = int(input())
b_sum = 0
Q1 = []
Q = []
vars = []
for _ in range(N):
    Qu = list(map(int, input().split()))
    Q.append(Qu)
    if Qu[0]==1:
        _, a, b = Qu
        vars.append(a)
        #b_sum += b
    else:
        pass
vars = list(set(vars))
vars.sort()
d = dict((v, i) for i, v in enumerate(vars))
lend = len(d)
bit = Bit(lend)
bit2 = Bit(lend)
n = 0
for q in Q:
    if q[0]==1:
        _, a, b = q
        bit.add(d[a], a)
        bit2.add(d[a], 1)
        b_sum += b
        n += 1
    else:
        l, r = 0, len(vars)
        con = (n - 1) >> 1
        while l+1 < r:
            c = (l+r)>>1
            cnt = bit2.sum(c)
            if cnt <= con:
                l = c
            else:
                r = c
        idx = l
        v = vars[idx]
        m = bit2.sum(idx)
        s = bit.sum(idx)
        m_ = bit2.sum(lend) - m
        s_ = bit.sum(lend) - s
        ans = b_sum + m*v-s + s_-m_*v
        print(v, ans)


Measured memory_bytes: 120912
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <numeric>
#include <climits>
#include <math.h>
#include <memory.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int N, M;
int cnt = 0;
ll ans = 0LL;
int i_index;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};
string board[64];

int main(){
    double A, B;
    cin >> A >> B;
    if(A > B) cout << "GREATER" << endl;
    else if(A < B) cout << "LESS" << endl;
    else cout << "EQUAL" << endl;
    return 0;
}


Measured memory_bytes: 256
/*
 * main.cpp
 *
 *  Created on: 2011/04/08
 *      Author: satoki
 *      4:50 ~ 5:01
 */
#include <iostream>
#include <string.h>
using namespace std;

int iN;

bool input() {
  scanf("%d", &iN);
  return true;
}

int manage() {
  int k = 100;
  int m;
  int i;
  for (i = 0; i < iN; i++) {
    m = k * 5;
    if (m % 100 != 0) m += 100;
    m /= 100;
    k += m;
  }
  return k;
}

int main() {
  input();
  printf("%d000\n", manage());
  return 0;
}

Measured memory_bytes: 0
N, *X = map(int, open(0).read().split())

MOD = 10 ** 9 + 7

fact = 1
for i in range(2, N):
    fact = fact * i % MOD

fact_list = [fact]
for i in range(2, N):
    fact_list.append(fact_list[-1] + fact * pow(i, MOD - 2, MOD) % MOD)

ans = 0
for i in range(N - 1):
    ans = (ans + (X[i + 1] - X[i]) * fact_list[i]) % MOD
    
print(ans % MOD)


Measured memory_bytes: 70312
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(int i = (N) - 1; i >= 0; i--)
#define rep1(i,N) for(int i = 1; i <= (N) ; i++)
#define repr1(i,N) for(int i = (N) ; i > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
using namespace std; void solve();
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cout << #v << " = "; array_out(v , N);cout << endl;} while(0)
  int main(){solve_dbg();}
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif

using P = pair<int,int>;
constexpr int MOD = 1000000007;
random_device seed_gen; mt19937_64 mtrand(seed_gen());

//////////////////////////////////////////

void solve(){
  ini(N);
  rep(i , N) {
    for(int j = i + 1; j < N ; j++){
      cout << (j==i+1?"":" ") << __builtin_ffs(i^j);
    }
    cout << '\n';
  }
}

Measured memory_bytes: 512