akhauriyash/Code-Regression huggingface dataset:
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)(x.size()))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     makep           make_pair
#define     maket           make_tuple
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)+(x)-1)/(x))
#define     gcd(a,b)        (__gcd((a),(b)))
#define     lcm(a,b)        (((a)*(b))/gcd((a),(b)))
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define     show2(x)        for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ld pi=acos(-1);
const ll inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    int n;
    cin>>n;

    set<string> st;
    string s;
    for(int i=0;i<n;++i)
    {
        cin>>s;
        st.ins(s);
    }

    cout<<sz(st);
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 19272
import java.util.*;

public class Main {

    static int n;
    static int[] lazy;
    static int[] node;
    static int INF = (1<<31)-1;

    static void eval(int k, int l, int r) {
        if (lazy[k]!=INF) {
            node[k] = lazy[k];
            if (r-l>1) {
                lazy[2*k+1] = lazy[k];
                lazy[2*k+2] = lazy[k];
            }
            lazy[k] = INF;
        }
    }

    static void update(int a, int b, int x, int k, int l, int r) {
        eval(k, l, r);
        if (a<=l && r<=b) {
            lazy[k] = x;
            node[k] = x;
            eval(k, l, r);
        } else if (b<=l || r<=a) {
        } else {
            update(a, b, x, 2*k+1, l, (l+r)/2);
            update(a, b, x, 2*k+2, (l+r)/2, r);
            node[k] = Math.min(node[2*k+1], node[2*k+2]);
        }
    }

    static int query(int a, int b, int k, int l, int r) {
        eval(k, l, r);
        if (a<=l && r<=b) {
            return node[k];
        } else if (b<=l || r<=a) {
            return INF;
        } else {
            int vl = query(a, b, 2*k+1, l, (l+r)/2);
            int vr = query(a, b, 2*k+2, (l+r)/2, r);
            return Math.min(vl, vr);
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n_ = sc.nextInt();
        n = 1;
        while (n<n_) n*=2;
        lazy = new int[2*n-1];
        node = new int[2*n-1];
        Arrays.fill(lazy, INF);
        Arrays.fill(node, INF);

        int q = sc.nextInt();
        for (int i=0;i<q;i++) {
            int com = sc.nextInt();
            if (com==0) {
                int s = sc.nextInt();
                int t = sc.nextInt();
                int x = sc.nextInt();
                update(s, t+1, x, 0, 0, n);
            } else { // com==1
                int s = sc.nextInt();
                int t = sc.nextInt();
                System.out.println(query(s, t+1, 0, 0, n));
            }
        }
        // System.out.println(Arrays.toString(lazy));
        // System.out.println(Arrays.toString(node));
    }
}


Measured memory_bytes: 117392
#include <bits/stdc++.h>
using namespace std;
int main () {

	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i ++) {
		if (s[i] == '1') s[i] = '9';
		else if (s[i] == '9') s[i] = '1';
	}
	
	cout << s;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define ITR(x, c) for(__typeof(c.begin()) x = c.begin(); x != c.end(); x++)
#define all(v) v.begin(), v.end()
#define inputv(v, n)                                                           \
    vl v;                                                                      \
    rep(i, n) {                                                                \
        ll x;                                                                  \
        cin >> x;                                                              \
        v.push_back(x);                                                        \
    }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans = 0;
int main() {
    cin>>n>>m;
    string S;
    vl WA(n+1,0),flag(n+1,0);
    rep(i,m){
        cin>>x>>S;
        if(S=="AC"&&flag[x]==0){
            ans+=WA[x];
            flag[x]=1;
        }
        else{
            WA[x]++;
        }
    }

    k=0;
    rep(i,n+1){
        k+=flag[i];
    }

    cout<<k<<" "<<ans<<endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
#define MaxN 110

const int oo = 0x7fffffff;
int g[MaxN][MaxN], d[MaxN];
bool used[MaxN], vst[MaxN];

int main()
{
    int min, n, m, max, tmp, pre, cur, a, b, w, cnt;

    while (scanf("%d%d", &n, &m), n) {
        min = oo, cnt = 0;
        memset(g, 0, sizeof(g));
        memset(used, 0, sizeof(used));
        int Res = 0;
        for (int i = 0; i < m; ++i) {
            scanf("%d%d%d", &a, &b, &w);
            if (w < 0){
                Res += w;
                continue;
            }
            g[a][b] += w;
            g[b][a] = g[a][b];
        }
        if (n < 2) {
            printf("%d\n",Res);
            continue;
        }
        for (int i = 1; i < n; ++i) {
            memset(vst, 0, sizeof(vst));
            vst[0] = 1;
            cur = pre = d[0] = 0;
            for (int k = 1; k < n; ++k) d[k] = g[0][k];
            for (int j = i; j < n; ++j) {
                max = 0;
                pre = cur;
                for (int k = 0; k < n; ++k) {
                    if (vst[k] || used[k]) continue;
                    if (d[k] > max) {
                        max = d[k];
                        cur = k;
                    }
                }
                vst[cur] = 1;
                for (int k = 0; k < n; ++k) {
                    if (vst[k] || used[k]) continue;
                    d[k] += g[cur][k];
                }
            }
            used[cur] = 1;
            for (int j = 0; j < n; ++j) {
                if (j == pre || used[j]) continue;
                g[pre][j] += g[cur][j];
                g[j][pre] = g[pre][j];
            }
            tmp = 0;
            for (int j = 0; j < n; ++j) {
                if (used[j]) continue;
                tmp += g[cur][j];
            }
            if (tmp < min) min = tmp;
            else continue;
        }
        printf("%d\n", Res+min);
    }
    return 0;
}

Measured memory_bytes: 816
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)      //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++) //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)    //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))        //array size
#define SORTD(a) sort(a,a+ASIZE(a),greater<int>()) //sort in descending order for array
#define SORTA(a) sort(a,a+ASIZE(a))                //sort in ascending order for array
#define SORTS(a) sort(a.begin(),a.end())           //sort in ascending order for string type
typedef long long LL;
typedef unsigned int UINT;
 
void SCAN(int *a){scanf("%d",a);}                             //scan for type int
void SCAN(int *a,int n){int i;REP(i,n){scanf("%d",&a[i]);}}   //scan for type int array
void SCAN(UINT *a){scanf("%u",a);}                            //scan for type unsigned int
void SCAN(UINT *a,int n){int i;REP(i,n){scanf("%u",&a[i]);}}  //scan for type unsigned int array
void SCAN(LL *a){scanf("%lld",a);}                            //scan for type long long int
void SCAN(LL *a,int n){int i;REP(i,n){scanf("%lld",&a[i]);}}  //scan for type long long int array
void SCAN(char *c){scanf(" %c",c);}                           //scan for type char
void SCAN(char *c,int n){int i;REP(i,n){scanf(" %c",&c[i]);}} //scan for type char array
 
const int MOD = 1000000007;
const int INF = 1000000000;
 
const int DX4[4]= {-1,0,0,1};
const int DY4[4]= {0,-1,1,0};
 
//fill an N-dimensional array with val
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
	fill((T*)array,(T*)(array+N),val);
}
 
int pascalTri(int n,int r){
	int tri[n+1][n+1];
	int i,j;
	REP(i,n+1){REP(j,n+1){tri[i][j]=0;}}
	REP(i,n+1){
		REP(j,n+1){
			if(j>i){break;}
			if(j==0||j==i){tri[i][j]=1;}else{tri[i][j]=(tri[i-1][j-1]%MOD+tri[i-1][j]%MOD)%MOD;}
		}
	}
	return tri[n][r];
}
 
 
int main(){
	// cin.tie(0);
	// ios::sync_with_stdio(false);
	int n,m;
	int i,j;
	
	SCAN(&n);SCAN(&m);

	int cost=1900*m+(n-m)*100;
	double p=1.;
	REP(i,m){
		p*=1/2.;
	}

	double E=0;
	double temp_p=p;
	i=1;
	while(temp_p>1*10e-30){

		E+=i*cost*temp_p;
		
		//cout<<i<<"*"<<cost<<"*1/"<<temp_p<<":"<<E<<endl;
		temp_p*=(1.-p);
		i++;
	}

 	printf("%d\n",(int)round(E));
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,x;
    cin>>n>>x;
    int ans=0;
    while(n!=0||x!=0){
        ans=0;
        for(int i=1;i<=n;i++){
            if(i>x){
                break;
            }
            for(int j=i+1;j<=n;j++){
                if(i+j>x){
                    break;
                }
                for(int k=j+1;k<=n;k++){
                    if(i+j+k==x){
                        ans++;
                    }
                }
            }
        }
        cout<<ans<<endl;
        cin>>n>>x;
    }
}


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

int main(){
  int n,m;
  cin>>n>>m;
  int ans;
  for(int i = m/n; i >= 1; i--){
    if((m-n*i)%i==0) {ans=i; break;}
  }
  cout<<ans<<endl;
}


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

class modint {
  public:
    using ll = long long;
    ll num;
    static const ll MOD = 1e9+7;
    static vector<modint> factorial;

    modint(): num(0) {};
    modint(ll _n): num((_n + MOD) % MOD) {}
    modint(const modint &r): num(r.num) {}
    operator ll() const { return (num+MOD)%MOD; }
    friend istream& operator>>(istream& is, modint &r){
        ll num_;
        is >> num_;
        r = num_;
        return is;
    }
    modint operator+(const modint &r) const { return modint(num + r.num); }
    modint operator-(const modint &r) const { return modint(num - r.num); }
    modint operator*(const modint &r) const { return modint(num * r.num); }

    template<typename T>
    modint operator^(const T &r) const {
        if(r == 0) return 1;
        return (((*this)*(*this)) ^ (r/2)) * modint(r&1 ? num : 1);
    }
    modint operator/(const modint &r) const { return num * (r^(MOD-2)); }

    modint operator+=(const modint &r) { return *this = *this + r; }
    modint operator-=(const modint &r) { return *this = *this - r; }
    modint operator*=(const modint &r) { return *this = *this * r; }
    modint operator/=(const modint &r) { return *this = *this / r; }

    template<typename T>
    modint operator^=(const T &r) { return *this = *this ^ r; }

    static modint fact(int n){
        if((int)factorial.size() <= n) factorial.resize(n+1);
        if(factorial[n]) return factorial[n];
        if(n == 0) return 1;
        return factorial[n] = modint(n) * fact(n-1);
    }

    static modint com(ll n,ll r){
        return n >= r ? fact(n)/(fact(n-r)*fact(r)) : modint(0);
    }
};
vector<modint> modint::factorial;

modint dp[102][10];
modint fibs[10];

modint fib(int n) {
    if (n < 2) return n;
    if (fibs[n] != 0LL) return fibs[n];
    return fibs[n] = fib(n-1) + fib(n-2);
}

modint f(int x) {
    if (x<=0) return 1;
    else return fib(x+2);
}

int main(void){
    int Y,X,K;
    cin>>Y>>X>>K;
    dp[0][1] = 1;
    rep(y,Y+1){
        rep1(x,X){
            dp[y+1][x-1] += dp[y][x] * f(x-3) * f(X-1-x);
            dp[y+1][x]   += dp[y][x] * f(x-2) * f(X-1-x);
            dp[y+1][x+1] += dp[y][x] * f(x-2) * f(X-2-x);
        }
    }
    cout << dp[Y][K] << endl;
    return 0;
}


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

int isStable(char in[36][3] ,char out[36][3]);
int N;

int main(){

  int i,j,min;
  char C[36][3],num[36][3],A[36][3],tmp[36];

  scanf("%d",&N);
 
  for(i=0;i<N;i++){
    scanf("%s",C[i]);
    strcpy(num[i],C[i]);
    strcpy(A[i],C[i]);
  }

  for(i=0;i<N;i++){
    for(j=N-1;j > i;j-- ){
      if(C[j][1]<C[j-1][1]){
	strcpy(tmp,C[j]);
	strcpy(C[j],C[j-1]);
	strcpy(C[j-1],tmp);
      }
    }
  }
  for(i=0;i<N-1;i++)
    printf("%s ",C[i]);

    printf("%s\n",C[i]);

    
    if((isStable(num,C))==1)printf("Stable\n");
    else printf("Not stable\n");


  
for(i=0;i<N;i++){
    min=i;
    for(j=i;j<N;j++){
      if(A[j][1]<A[min][1])min=j;
    }
    strcpy(tmp,A[i]);
    strcpy( A[i],A[min]);
    strcpy( A[min],tmp);
 }

  for(i=0;i<N-1;i++)
    printf("%s ",A[i]);

  printf("%s\n",A[i]);
  

  if((isStable(num,A))==1)printf("Stable\n");
    else printf("Not stable\n");

  return 0;
}

int isStable(char in[36][3] , char out[36][3]){

  int i,j,a,b;

  for(i=0;i<N;i++){
    for(j=i+1;j<N;j++){
      for(a=0;a<N;a++){
	for(b=a+1;b<N;b++){
	  if((in[i][1]==in[j][1])&&(strcmp(in[i],out[b])==0)&&(strcmp(in[j],out[a])==0))return 0;
	}
      }
    }
  }
  return 1;
 
}

Measured memory_bytes: 624
#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;
struct money
{
	int a,b;
	inline bool operator<(const money &x)const
	{
		return a<x.a;
	} 
}x[100005];
priority_queue<int> line;
int main()
{
	int n,m,s=0,i,j=1;
	cin>>n>>m;
	for(int i=1;i<=n;i++) cin>>x[i].a>>x[i].b;
	sort(x+1,x+n+1);
	for(i=1;i<=m;i++)
	{
		for(;x[j].a==i&&j<=n;j++)
		{
			line.push(x[j].b);
		}
		if(!line.empty())
		{
			s+=line.top();
			line.pop();
		}
	}
	cout<<s;
	return 0;
} 

Measured memory_bytes: 1660
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define sz 200009
vector<ll>v,v1,v2,v3,v4;
int main()
{
    ll x,y,z,a,b,c,i,j,k;
    k=0;
    scanf("%lld %lld %lld %lld %lld",&x,&y,&a,&b,&c);
    for(i=0;i<a;i++)
    {
        scanf("%lld",&j);
        v.push_back(j);
    }
    for(i=0;i<b;i++)
    {
        scanf("%lld",&j);
        v1.push_back(j);
    }
    for(i=0;i<c;i++)
    {
        scanf("%lld",&j);
        v2.push_back(j);
    }
    sort(v.begin(),v.end());
    sort(v1.begin(),v1.end());
    sort(v2.begin(),v2.end());
    reverse(v.begin(),v.end());
    reverse(v1.begin(),v1.end());
    reverse(v2.begin(),v2.end());
    k=0;
    for(i=0;i<x;i++)
    {
        k+=v[i];
    }
    for(i=a-1;i>=x;i--)
        v.pop_back();
    for(i=0;i<y;i++)
    {
        k+=v1[i];
    }
    for(i=b-1;i>=y;i--)
        v1.pop_back();
   // printf("%lld\n",k);
    for(i=0;i<c;i++)
    {
        if(!v.empty())
        a=v.back();
        else
            a=INT_MAX;
        if(!v1.empty())
        b=v1.back();
        else
            b=INT_MAX;
        if(v2[i]>a || v2[i]>b)
        {
            if(v2[i]>a && v2[i]>b)
            {
                if(a<b)
                {
                    v.pop_back();
                    k-=a;
                    k+=v2[i];
                }
                else
                {
                    v1.pop_back();
                    k-=b;
                    k+=v2[i];
                }
            }
            else if(v2[i]>a)
            {
                v.pop_back();
                    k-=a;
                    k+=v2[i];
            }
            else
            {
                v1.pop_back();
                    k-=b;
                    k+=v2[i];
            }
        }
    }
    printf("%lld\n",k);
    }


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

typedef struct{
  int n;
  char name[10];
  int p;
}res;


void swap(res *a, res *b){
  res c;
  c = *a;
  *a = *b;
  *b = c;
}


void bubble_sort_name(res *a, int n){
  int i, j;
  for(i=0; i<n-1; i++)
    for(j=0; j<n-1; j++)
      if(strcmp(a[j].name, a[j+1].name) > 0 )
	swap(&a[j], &a[j+1]);
}


void bubble_sort_point(res *a, int n){
  int i, j;
  for(i=0; i<n-1; i++)
    for(j=0; j<n; j++)
      if(strcmp(a[j].name, a[j+1].name) == 0 &&
	 a[j].p < a[j+1].p)
	swap(&a[j], &a[j+1]);
}


int main(void){
  int N;
  scanf("%d", &N);
  int i;
  res list[N];
  for(i=0; i<N; i++){
    scanf("%s%d", list[i].name, &list[i].p);
    list[i].n = i+1;
  }
  bubble_sort_name(list, N);  
  bubble_sort_point(list, N);

  for(i=0; i<N; i++)
    printf("%d\n",list[i].n);

  return 0;
}


Measured memory_bytes: 128
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Joy
 */

#include <bits/stdc++.h>

#define REP(i, N) for (ll i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF ll(1e9)
#define INFL ll(1e18)
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int ctoi(char c) {return c - '0';}

class BStringPalindrome {
public:
	void solve(std::istream& in, std::ostream& out) {
	    string S; in >> S;
	    int N = S.size();
	    string ans = "Yes";
	    REP(i, N) {
	        if (S[i] != S[N-1 - i]) {
	            ans = "No";
	            break;
	        }
	    }
	    REP(i, N/2) {
	        if (S[i] != S[N/2-1 - i]) {
	            ans = "No";
	            break;
	        }
	    }
	    out << ans << '\n';
	}
};


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

	BStringPalindrome solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	cout << ((a == b && b == c) ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int color = 0;
  int F = 0;
  for (int i = 0; i < N; i++){
    int a;
    cin >> a;
    if (a < 3200){
      color |= (1 << (a / 400));
    } else {
       F++;
    }
  }
  cout << max(__builtin_popcount(color), 1) << ' ' << __builtin_popcount(color) + F;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(void){
    
    string str, com, h, h2;
    int n, a, b, i;
    
    cin >> str;
    cin >> n;
    
    for(i=0;i<n; i++){
        cin >> com >> a >> b;
        if(com == "print"){
            h = str.substr(a, b-a+1);
            cout << h << endl;
        }else if(com == "reverse"){
            h2 = str.substr(a, b-a+1);
            reverse(h2.begin(), h2.end());
            str.replace(a, b-a+1, h2);
        }else if(com == "replace"){
            cin >> h;
            str.replace(a,b-a+1,h);
        }
    }
    
    
    
    return 0;
}



Measured memory_bytes: 3220
module Main where

-- import Debug.Trace
import Data.List
import qualified Data.Sequence as S
import qualified Data.ByteString.Char8 as B
import Data.Int
import Data.Char
import Data.Array
import Data.Maybe
import qualified Data.Map as M
import Data.Ord
import Data.Functor
import Control.Applicative
import Control.Monad
import Text.Printf

data Tree a = Nil | Node a (Tree a) (Tree a) deriving (Show)
data Command = Print | Insert Int | Find Int deriving (Show)
data Order = Preorder | Inorder deriving (Eq, Show)

sFind   = B.pack "find"
sInsert = B.pack "insert"
sPrint  = B.pack "print"

solve :: [Command] -> [String]
solve = iter Nil where
    iter :: Tree Int-> [Command] -> [String]
    iter _ [] = []
    iter rt (c:cs) = case c of
        Print    -> (inorder rt):(preorder rt):(iter rt cs)
        Find x   -> (find x rt):(iter rt cs)
        Insert x -> iter (insert x rt) cs
    
    find x = iter where
        iter (Node y l r)
            | x == y = "yes"
            | x <  y = iter l
            | x >  y = iter r 
        iter Nil = "no"

    insert x = iter where
        iter (Node y l r)             
            | x < y     = Node y (iter l) r
            | otherwise = Node y l (iter r) 
        iter Nil = Node x Nil Nil 

    preorder = toString . (toList Preorder)
    inorder  = toString . (toList Inorder)

toList :: Ord a => Order -> Tree a -> [a]
toList ord = iter where
    iter Nil = []
    iter (Node id l r)
        | ord == Preorder = id:(iter l) ++ iter r
        | ord == Inorder  = (iter l) ++ id:iter r

toString:: [Int] -> String
toString [] = []
toString (x:xs) = ' ':(show x)++ toString xs

toInt :: B.ByteString -> Int
toInt = fst . fromJust . B.readInt
                    
readIntLn:: IO Int
readIntLn = toInt <$> B.getLine

readCommand:: IO Command
readCommand = do
    l <- B.words <$> B.getLine
    return $ case l of
        [cmd, n]
            | cmd == sFind   -> Find   $ toInt n
            | cmd == sInsert -> Insert $ toInt n
        [sPrint]     -> Print

main :: IO() 
main = do
    n <- readIntLn
    l <- replicateM n readCommand
    mapM_ putStrLn $ solve l



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

int main(void)
{
	int n, m;
	int num_line[100000];
	int sum, sum_max;
	int i, k;
	
	while (1){
		scanf("%d%d", &n, &m);
		
		if (n == 0 && m == 0)	break;
		
		sum_max = sum = 0;
		for (i = 0; i < n; i++){
			num_line[i] = 0;
			scanf("%d", &num_line[i]);
			if (i <= m - 1){
				sum += num_line[i];
				sum_max = sum;
			}
			else if (i > m - 1){
				sum = sum - num_line[i - m] + num_line[i];
				
				if (sum > sum_max){
					sum_max = sum;
				}
			}
		}
		
		printf("%d\n", sum_max);
	}
	return (0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#ifdef _LOCAL_DEBUG
#include "templates/debug.h"
#else
#define debug(...)
#endif

constexpr int mxn = 3001;
ll dp[mxn][mxn][4], a[mxn][mxn];
int r, c, n;

void maxi(ll& x, ll y) {
    x = max(x, y);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> r >> c >> n;
    for (int x = 0; x < n; x++) {
        int i, j, v;
        cin >> i >> j >> v;
        a[i - 1][j - 1] = v;
    }
    dp[0][0][1] = a[0][0];
    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            for (int k = 0; k <= 3; k++) {
                if (i + 1 < r) {
                    maxi(dp[i + 1][j][0], dp[i][j][k]);
                    if (a[i + 1][j] != 0)
                        maxi(dp[i + 1][j][1], dp[i][j][k] + a[i + 1][j]);
                }
                if (j + 1 < c) {
                    maxi(dp[i][j + 1][k], dp[i][j][k]);
                    if (k < 3 && a[i][j + 1] != 0)
                        maxi(dp[i][j + 1][k + 1], dp[i][j][k] + a[i][j + 1]);
                }
            }
        }
    }
    cout << *max_element(dp[r - 1][c - 1], dp[r - 1][c - 1] + 4);
    return 0;
}

Measured memory_bytes: 355292
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

const int MAXN = 2e5 + 10;

typedef long long ll;

int n;
int A[MAXN], B[MAXN];
vector<int> abit[40], bbit[40];
int bcnt[60];

int main() {
	scanf("%d", &n);

	for (int i = 0; i < n; i++) {
		scanf("%d", &A[i]);
		for(int j=0;j<28;j++){
			if((A[i]>>j)&1) abit[j].push_back(A[i]);
		}
	}

	for (int i = 0; i < n; i++) {
		scanf("%d", &B[i]);
		for(int j=0;j<28;j++){
			if((B[i]>>j)&1) bbit[j].push_back(B[i]);
		}
	}

	for(int b=0;b<30;b++) {
		int aocnt = abit[b].size();
		int azcnt = n - aocnt;
		
		int bocnt = bbit[b].size();
		int bzcnt = n - bocnt;
		
		azcnt &= 1, aocnt &= 1;
		bzcnt &= 1, bzcnt &= 1;

		bcnt[b] += azcnt*bocnt + bzcnt*aocnt;
		bcnt[b] &= 1;

		vector<int> C(n);
		for(int i=0;i<n;i++) {
			C[i] = B[i]%(1<<b);
		}
		sort(C.begin(), C.end());
		
		int carry = 0;
		for(int i=0;i<n;i++) {
			int lim = (1<<b) - (A[i]%(1<<b));

			int lbidx = lower_bound(C.begin(), C.end(), lim) - C.begin();
			carry += n-lbidx;
			carry &= 1;
		}

		bcnt[b] += carry;
		bcnt[b] &= 1;
	}

	int ans=0;
	for(int i=0;i<30;i++) {
		ans += (1<<i)*bcnt[i];
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 28072
#include <iostream>
#include <vector>
using namespace std;
#define C

#ifdef C
#define BIL 4
#define FLO	3
#define ROO	10
int main(void)
{
	unsigned char rooms[BIL][FLO][ROO] = {};
	int num;
	cin >> num;
	for (size_t i = 0; i < num; i++)
	{
		int b, f, r, v;
		cin >> b >> f >> r >> v;
		rooms[b - 1][f - 1][r - 1] += v;
	}
	for (size_t i = 0; i < BIL; i++)
	{
		if (i!=0)
		{
			for (size_t j = 0; j < ROO; j++)
			{
				cout << "##";
			}
			cout << endl;
		}
		for (size_t j = 0; j < FLO; j++)
		{
			for (size_t k = 0; k < ROO; k++)
			{

				cout << " "<< static_cast<int>(rooms[i][j][k]);
			}
			cout << endl;
		}

	}
		return 0;
}
#endif // !C

Measured memory_bytes: 3076
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n,m;
int main(){
    cin>>n>>m;
    cout<<n*(n-1)/2+m*(m-1)/2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;

typedef long long ll;

ll N, M;
ll mod = 1e9 + 7;

ll calc(int n) {
    ll res = 1;
    while (n > 0) {
        // cout << res << endl;
        res *= n;
        res = res % mod;
        n--;
    }
    return res;
}
int main() {
    cin >> N >> M;

    if (abs(N - M) > 1) {
        cout << 0 << endl;
        return 0;
    }

    ll target_min = min(M, N);
    ll target_max = max(M, N);

    ll num = calc(target_min);
    // cout << calc(target_min) << endl;
    // return 0;

    if (N == M) {
        cout << (((num * num) % mod) * 2) % mod << endl;
    } else {
        cout << (((num * num) % mod) * target_max) % mod << endl;
    }
}

Measured memory_bytes: 384
#include <iostream>

#include <vector>

#include <algorithm>

using namespace std;



int main() {

    int N;

    cin >> N;

    vector<int> sides(3);

    for (int n = 0; n != N; ++n) {

        cin >> sides[0] >> sides[1] >> sides[2];

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

        if (sides[0]*sides[0] + sides[1]*sides[1] == sides[2]*sides[2]) {

            cout << "YES" << endl; 

        }

        else {

            cout << "NO" << endl;

        }

    }

    return 0;

}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define repb(bit, n, init) for (ll bit = init; bit < (1 << n); ++bit)

int main()
{
    ll n, r = 0, g = 0, b = 0;
    cin >> n;
    string s;
    cin >> s;

    ll cnt = 0;
    repi(i, n, 0)
    {
        s.at(i) == 'R' ? r++ : r;
        s.at(i) == 'G' ? g++ : g;
        s.at(i) == 'B' ? b++ : b;
    }
    repi(i, n, 0)
    {
        repi(j, n, i)
        {
            ll k = 2 * j - i;
            if (k < n && 0 <= k)
            {
                if (s.at(i) != s.at(j) && s.at(j) != s.at(k) && s.at(k) != s.at(i))
                {
                    cnt++;
                }
            }
        }
    }
    cout << r * g * b - cnt << endl;
    return 0;
}

Measured memory_bytes: 3584
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
using namespace std;
typedef long long int lli;
int main(void)
{
    int A, B;
    cin >> A;
    cin >> B;
    if (A >= 13)
    {
        cout << B << endl;
    }
    else if (6 <= A && A <= 12)
    {
        cout << B / 2 << endl;
    }
    else
    {
        cout << "0" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <algorithm>
#define repu(i,x,y) for (int i=x; i<=y; ++i)
#define repe(i,x) for (edge *i=fst[x]; i; i=i->nxt)
using namespace std;

typedef long long LL;
int n,s[100100],f[100100],root;
LL ans,dep[100100];
struct edge
{
    int v,w;
    edge *nxt;
} pool[200100],*tp=pool,*fst[100100];

int getint()
{
    char ch;
    while (!isdigit(ch=getchar()));
    int x=ch-'0';
    for (; isdigit(ch=getchar()); x=x*10+ch-'0');
    return x;
}

void dfs1(int x,int fa)
{
    s[x]=1;
    repe(i,x)
        if (i->v!=fa)
            dfs1(i->v,x),f[x]=max(f[x],s[i->v]),s[x]+=s[i->v];
    if ((f[x]=max(f[x],n-s[x]))<f[root])
        root=x;
}

void dfs2(int x,int fa)
{
    ans+=dep[x]*2,s[x]=1;
    repe(i,x)
        if (i->v!=fa)
            dep[i->v]=dep[x]+i->w,dfs2(i->v,x),s[x]+=s[i->v];
}

int main()
{
    n=getint();
    repu(i,2,n)
    {
        int u=getint(),v=getint(),w=getint();
        *tp=(edge){v,w,fst[u]},fst[u]=tp++;
        *tp=(edge){u,w,fst[v]},fst[v]=tp++;
    }
    f[0]=1<<30,dfs1(1,0),dfs2(root,0);
    LL mind=1LL<<60;
    repe(i,root)
        if (s[i->v]*2==n)
        {
            printf("%lld\n",ans-dep[i->v]);
            return 0;
        }
        else
            mind=min(mind,dep[i->v]);
    printf("%lld\n",ans-mind);
    return 0;
}

Measured memory_bytes: 9600
#include<vector>
#include<bitset>
#include<iostream>
using namespace std;
#define df 0
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=a;i<(n);i++)
typedef long int li;

class mono{
public:
  bitset<26> st;
  
  // constructor
  mono(){  }
  mono(bitset<26> s){ st=s; }
  mono(char c){ st[c-'a']=1; }
  int get(){
    int f=0;
    rep(i,26) f+=st[i];
    return f;
  }
  // addition
  mono operator+(mono m);
  // print
  //  void print(){for(const char& x:st) printf("%c",x);}
};


///  Segment Tree  (prototype)  ///
template<typename Monoid>
class SegTree{
  int n;
  vector<Monoid> node;
  
public:
  int parent(int a){return (a-1)/2;}
  int  left(int a) {return (a*2+1);}
  int right(int a) {return (a*2+2);}
  int leaf(int a){return (a+n-1);}
  SegTree(vector<Monoid> v);
  SegTree(int k);
  void update(int i,Monoid x);
  Monoid find(int a,int b,int i,int l,int r);
  Monoid find(int a,int b){return find(a,b,0,0,n);}
  Monoid find(int a){return node.at(leaf(a));}
  // void print(){
  //   for(int i=0;i<2*n-1;i++){
  //     printf("%d: ",i);
  //     node.at(i).print();
  //     printf("\n");
  //   }
  // }
};
///  Segment Tree  ///


int main(){
  if(df) printf("*debug mode*\n");
  int n; string s; cin >>n >>s;
  vector<mono> vec(n);
  rep(i,n) vec[i]=s.at(i);
  SegTree<mono> sgt(vec);
  //  if(df) sgt.print();
  int q; cin >>q;
  rep(_,q){
    int f; cin >>f;
    if(f==1){
      int i; char c; cin >>i >>c; i--;
      sgt.update(i,{c});
      if(df)printf("update\n");
    }else{
      int i,j; cin >>i >>j; i--;
      if(df)printf("find [%d %d)",i,j);
      cout << sgt.find(i,j).get() << "\n";
    }
  }
}

mono mono::operator+(mono m){
  return (m.st|this->st);
}


///  Segment Tree  (main)  ///
template<typename Monoid>
SegTree<Monoid>::SegTree(vector<Monoid> v){
  int sz=v.size();
  n=1; while(n<sz)n*=2;
  node.resize(2*n-1);
  for(int i=0;i<v.size();i++){
    node.at(i+n-1)=v.at(i);
  }
  for(int i=n-2;i>=0;i--){
    node.at(i)=node.at(this->left(i))+node.at(right(i));
  }
}
template<typename Monoid>
SegTree<Monoid>::SegTree(int k){
  int sz=k;
  n=1; while(n<sz)n*=2;
  node.resize(2*n-1);
}

template<typename Monoid>
void SegTree<Monoid>::update(int i,Monoid x){
  i=this->leaf(i);
  node.at(i)=x;
  while(i>0){
    i=this->parent(i);
    node.at(i)=node.at(this->left(i))+node.at(this->right(i));
  }
}
template<typename Monoid>
Monoid SegTree<Monoid>::find(int a,int b,int i,int l,int r){
  Monoid x;
  if(df)printf(" find[%d,%d)",l,r);
  if(r<=a || b<=l)return x;
  if(a<=l && r<=b){
    if(df)printf("!");
    return node.at(i);
  }
  Monoid m1=find(a,b,this->left(i) ,l,(l+r)/2);
  Monoid m2=find(a,b,this->right(i),(l+r)/2,r);
  x=m1+m2;
  return x;
}
///  Segment Tree  ///


/// confirm df==0 ///


Measured memory_bytes: 16900
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
int n,m;
cin >> n >> m;
int ans[m]={0};
int k;
int temp;
REP(i,n) {
  cin >> k;
  REP(j,k) {
    cin >> temp;
    ans[temp-1]++;
  }
}
int count=0;
REP(i,m) {
  if(ans[i]==n) count++;
}
cout << count << endl;
return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    string n;

    cin >> n;

    for (int i = 0; i < 3; i++)
    {
        if (n[i] == '1')
        {
            n[i] = '9';
        }
        else
        {
            n[i] = '1';
        }
    }

    cout << n << endl;
}

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

using namespace std;

typedef vector<int> Vec;
typedef vector<Vec> Mat;

Mat a(5, Vec(5));
int score[5];

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

bool inField(int x, int y)
{
    return (0 <= x && x < 5 && 0 <= y && y < 5);
}

int erase(Mat &m)
{
    bool e[5][5] = {{}};
    for (int i = 0; i < 5; i++) {
        for (int j = 0; j < 5; j++) {                        
            if (m[i][j] == 0) {
                continue;
            }
            int cnt[2] = {1, 1};
            for (int k = 0; k < 4; k++) {
                int ni = i + dy[k];
                int nj = j + dx[k];
                while (inField(ni, nj) &&
                       m[i][j] == m[ni][nj]) {
                    ni += dy[k];
                    nj += dx[k];
                    ++cnt[k&1];
                }
            }
            if (cnt[0] >= 3 || cnt[1] >= 3) {
                e[i][j] = 1;
            }
        }
    }
    int point = 0;
    for (int i = 0; i < 5; i++) {
        for (int j = 0; j < 5; j++) {
            if (e[i][j]) {
                point += score[m[i][j]-1];
                m[i][j] = 0;
            }
        }
    }
    return point;
}

void fall(Mat &m)
{
    for (int j = 0; j < 5; j++) {
        for (int i = 4; i >= 1; i--) {
            if (m[i][j] == 0) {                
                for (int k = i-1; k >= 0; k--) {
                    if (m[k][j] != 0) {
                        swap(m[i][j], m[k][j]);
                        break;
                    }
                }
            }
        }
    }
}

int get_point()
{
    Mat b = a;
    int point = 0, bp = 1;
    bool update = 1;
    
    while (update) {
        update = 0;        
        Mat nb = b;
        point += erase(nb) * bp++;
        fall(nb);
        if (nb != b) {        
            update = 1;
            b = nb;
        }
    }
    return point;
}

int dfs(int y, int x, int n, int p)    
{
    int point = get_point();
    if (n > 0) {
        for (int i = 0; i < 4; i++) {
            int nx = x + dx[i];
            int ny = y + dy[i];
            if (inField(nx, ny) && (p == -1 || (p + 2) % 4 != i)) {
                swap(a[ny][nx], a[y][x]);
                point = max(point, dfs(ny, nx, n-1, i));
                swap(a[ny][nx], a[y][x]);
            }        
        }
    }
    return point;
}

int main()
{
    int n;
    while (cin >> n, n != -1) {
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 5; j++) {
                cin >> a[i][j];
            }
        }
    
        for (int i = 0; i < 5; i++) {
            cin >> score[i];
        }

        int max_point = 0;
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 5; j++) {
                max_point = max(max_point, dfs(i, j, n, -1));
            }
        }   
        cout << max_point << endl;
    }
    return 0;
}

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

int main() {
  int n;
  std::cin >> n;
  std::vector<int64_t> a1(n), a2(n);
  for (auto &i : a1) {
    std::cin >> i;
  }
  for (auto &i : a2) {
    std::cin >> i;
  }

  int64_t count = 0;

  for (int i = 0; i < n; i++) {
    int64_t tmp = 0;
    for (int j = 0; j < n; j++) {
      if (j < i) {
        tmp += a1[j];
      } else if (j == i) {
        tmp += a1[j] + a2[j];
      } else {
        tmp += a2[j];
      }
    }
    count = std::max(count, tmp);
  }

  std::cout << count << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<utility>
#include<tuple>
#include<set>
#include<list>
#include<vector>
#include<map>
#include<algorithm>
#include<queue>

//#define dump(x)  cerr << #x << " = " << (x) << endl;
//#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FUNCTION__ << endl;
#define dump(x) while(false){}
#define debug(x) while(false){}

#define int long long

const long long MAXN = 1e6;
const long long MOD = 1e9+7;
const long long INF = __LONG_LONG_MAX__ / 2;

using namespace std;

signed main(){
    int N;
    cin >> N;
    int maxsum = -INF;
    vector<int> a = vector<int>(3 * N);
    for (int i = 0; i < 3 * N; i++) cin >> a[i];


    priority_queue <int, vector<int>, greater<int>> la;
    for (int i = 0; i < N; i++) la.push(a[i]);
    int suml = 0;
    for (int i = 0; i < N; i++) suml+=a[i];
    vector<int> sumls = vector<int>(N+1);
    sumls[0] = suml;
    for (int k = N; k < 2*N ; k++) {
      suml += a[k];
      la.push(a[k]);
      debug(suml);

      suml -= la.top();
      debug(suml);
      la.pop();
      sumls[k-N+1] = suml;
    }

    priority_queue <int> ra;
    for (int i = 2*N; i < 3*N; i++) ra.push(a[i]);
    int sumr = 0;
    for (int i = 2*N; i < 3*N; i++) sumr+=a[i];
    vector<int> sumrs = vector<int>(N+1);
    sumrs[N] = sumr;
    for (int k = 2*N-1; k >= N ; k--) {
      sumr += a[k];
      ra.push(a[k]);
      debug(sumr);

      sumr -= ra.top();
      debug(sumr);
      ra.pop();
      sumrs[k-N] = sumr;
    }

    for (int i = 0; i <= N; i++) {
      dump(sumls[i]);
      dump(sumrs[i]);
      maxsum = max(maxsum, sumls[i]-sumrs[i]);
    }

    cout << maxsum;
    return 0;
}


Measured memory_bytes: 5876
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int H, W, N;
vector<int> A;
void input() {
  cin >> H >> W;
  cin >> N;
  A.resize(N);
  rep(i, 0, N - 1) {
    cin >> A[i];
  }

  ;
}

int used[100][100] = {};

int endh = 0, endw = 0;
vector<pii> vp;
// void dfs(int lim, int &cnt, int h, int w, int num) {
//   if (h < 0 || w < 0 || h >= H || w >= W) return;
//   if (used[h][w] != 0) return;
//   if (lim <= cnt) {
//     endh = h, endw = w;
//     return;
//   }

//   cnt++;
//   used[h][w] = num;

//   dfs(lim, cnt, h - 1, w, num);
//   dfs(lim, cnt, h, w - 1, num);
//   dfs(lim, cnt, h + 1, w, num);
//   dfs(lim, cnt, h, w + 1, num);
// }
void solve() {
  queue<int> q;
  rep(i, 0, N - 1) {
    while (A[i]) {
      q.push(i + 1);
      A[i]--;
    }
  }
  rep(i, 0, H - 1) {
    if (i % 2) {
      rep(j, 0, W - 1) {
        used[i][j] = q.front();
        q.pop();
      }
    } else {
      rrep(j, W - 1, 0) {
        used[i][j] = q.front();
        q.pop();
      }
    }
  }
  rep(i, 0, H - 1) {
    rep(j, 0, W - 1) { cout << used[i][j] << " "; }
    cout << endl;
  }
}
signed main() {
  input();
  solve();
  return 0;
}

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

int main()
{
  i64 n;
  cin >> n;
  cout << fixed << setprecision(10) << (double)((n + 1) / 2) / n << endl;
  return 0;
}


Measured memory_bytes: 256
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int n,sum = 0;
  cin >> n;
  vi v(n);

  rep(i,n)
  {
    cin >> v[i];
  }

  rep(i,n)
  for(int j = i; j < n; j++)
  {
    if(i == j)
      continue;

    sum += v[i] * v[j];
  }

  cout << sum;

  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


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

if N == 1:
    print(1)
elif N <4:
    print(2)
elif N<8:
    print(4)
elif N<16:
    print(8)
elif N<32:
    print(16)
elif N<64:
    print(32)
elif N<=100:
    print(64)

Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

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

int N;
vector<vector<int>> V;
vector<vector<int>> dp;
void solve();

int main() {
  cin >> N;
  V.assign(N, vector<int>(3, 0));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> V[i][j];
    }
  }
  dp.assign(N + 1, vector<int>(3, 0));
  solve();
}

void solve() {
  // 初期値である１日目
  for (int i = 0; i < 3; i++) {
    chmax(dp[0][i], V[0][i]);
  }

  // ２日目から最終日までを計算する
  for (int day = 1; day < N; day++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        if (j == k) {
          continue;
        }
        chmax(dp[day][k], dp[day - 1][j] + V[day][k]);
      }
    }
  }

  //最終日の最大値
  int max = 0;
  for (int i = 0; i < 3; i++) {
    chmax(max, dp[N - 1][i]);
  }

  cout << max << endl;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

int main(void){
	int N;
	cin >> N;
	ll A[N+1];
	ll ans [N+1];//各山に降った雨の量
	for(int i=0;i<N;i++){
		cin >> A[i];
	}
	ans[0] = A[0]+A[N-1];
	for(int i=1;i<N-1;i++){
		if(i%2==0)ans[0]+=A[i];
		else ans[0]-=A[i];
	}
	for(int i=0;i<N;i++){
		ans[i+1] = 2*A[i]-ans[i];
		cout << ans[i] <<" ";
	}
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n); i >= 0; i--)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define REVSORT(c) SORT(c);REVERSE(c)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
const long long MOD = 1000000007;
typedef long long ll;

int main(){
	string S;
	cin >> S;
	int N = S.length();
	N -= 8;
	rep(i, N)cout << S[i];
	cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int h, w, d; cin >> h >> w >> d;
    auto a = vec<int>(h, w); cin >> a;
    VI y(h * w), x(h * w);
    FOR(i, 0, h)FOR(j, 0, w) {
        --a[i][j];
        y[a[i][j]] = i;
        x[a[i][j]] = j;
    }

    VL acc(h * w);
    FOR(i, 0, h* w - d) {
        acc[i + d] = acc[i];
        acc[i + d] += abs(y[i] - y[i + d]);
        acc[i + d] += abs(x[i] - x[i + d]);
    }

    int q; cin >> q;
    while (q--) {
        int l, r; cin >> l >> r;
        --l, --r;
        cout << acc[r] - acc[l] << "\n";
    }
}

Measured memory_bytes: 2944