akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

int n, sx;
int x[MX];
ll c[MX];

ll ans;
inline int dist(int a, int b) { return abs(a-b);}
int dfs(int l, int r) {
  if (x[r] <= sx) {
    ans += dist(sx,x[l]);
    return x[l];
  }
  if (x[l] >= sx) {
    ans += dist(sx,x[r]);
    return x[r];
  }
  if (l==r) {
    ans += dist(x[l],sx);
    return x[l];
  }
  if (c[l] < c[r]) {
    c[r] += c[l];
    int nx = dfs(l+1,r);
    ans += dist(nx,x[l]);
    return x[l];
  } else {
    c[l] += c[r];
    int nx = dfs(l,r-1);
    ans += dist(nx,x[r]);
    return x[r];
  }
}

int main() {
  scanf("%d%d",&n,&sx);
  rep(i,n) {
    scanf("%d%lld",&x[i],&c[i]);
  }
  dfs(0,n-1);
  cout<<ans<<endl;
  return 0;
}






















Measured memory_bytes: 3968
#include<iostream>
using namespace std;
struct Card{
         char suit,value;
       };
       void bubble(struct Card A[],int N){
          for(int i = 0;i < N;i++){
            for(int j = N - 1;j >= i + 1;j--){
                if(A[j].value < A[j - 1].value){
                    Card t = A[j];
                    A[j] = A[j - 1];
                    A[j - 1] = t;
                }
            }
          }
       }
       void selection(struct Card A[],int N){
           for(int i = 0;i < N;i++){
             int minj = i;
             for(int j = i;j < N;j++){
                if(A[j].value < A[minj].value){
                    minj = j;
                }
             }
                    Card t = A[i];
                    A[i] = A[minj];
                    A[minj] = t;
           }
       }
       void print(struct Card A[],int N){
          for(int i = 0;i < N;i++){
                if(i > 0){
                    cout << " ";
                }
                cout << A[i].suit << A[i].value;
          }
          cout << endl;
       }
       bool isStable(struct Card C1[],struct Card C2[],int N){
         for(int i = 0;i < N;i++){
            if(C1[i].suit != C2[i].suit)
                return false;
         }
         return true;
       }
     int main(){
       Card C1[100],C2[100];
       int N;
       char ch;
       cin >> N;
       for(int i = 0;i < N;i++){
         cin >> C1[i].suit >> C1[i].value;
       }
       for(int i = 0;i < N;i++){
        C2[i] = C1[i];
       }
       bubble(C1,N);
       selection(C2,N);

       print(C1,N);
       cout << "Stable" << endl;
       print(C2,N);
       if(isStable(C1,C2,N)){
        cout << "Stable" << endl;
       }else{
        cout << "Not stable" << endl;
       }
       return 0;
}


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

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2")

using namespace std;

#define int long long
#define sz(a) (int) (a).size()
#define all(a) (a).begin(), (a).end()
#define x first
#define y second

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int p = 1e9 + 7;
const int maxn = 1e5 + 10;

int mul(int x, int y) {
    return (x * y) % p;
}

int bin_pow(int x, int m) {
    int res = 1;
    while (m) {
        if (m & 1) res = mul(res, x);
        x = mul(x, x);
        m >>= 1;
    }
    return res;
}

int ans[maxn];

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

    int n, k;
    cin >> n >> k;
    int res = 0;
    for (int i = k; i >= 1; i--) {
        ans[i] = bin_pow(k / i, n);
        for (int j = i * 2; j <= k; j += i) {
            ans[i] = (ans[i] - ans[j] + p) % p;
        }
        res = (res + mul(i, ans[i])) % p;
    }
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 4408
#include <bits/stdc++.h>
#define ll long  long
#define ld long double
#define mod 1000000007
#define max_char 128
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define lbd lower_bound
#define ubd upper_bound
#define PI 3.141592653589793238
#define pf push_front
#define all(x) x.begin(),x.end()
#define input(arr,n) for(ll c1=0;c1<n;c1++)cin>>arr[c1];
#define rep(i,a,n) for( ll i=a ; i<n ; i++)
#define mems(x, y) memset(x, y, sizeof(x))
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;


int main()
{
    fastio
	ll n,i,sum=0;
	cin>>n;
	ll a[n-1];
	input(a,n-1);
	map<ll,ll>m;
	for(i=0;i<n-1;i++)
	{
	    m[a[i]]++;
	}
	for(i=1;i<=n;i++)
	{
	    cout<<m[i]<<" ";
	}
	
	return 0;
}

Measured memory_bytes: 17712
def solve():
    N, K = map(int, input().split())
    if (N - 2)*(N - 1)//2 < K: print(-1)
    else:
        totalpath = (N-2)*(N-1)//2
        ans = []
        for i in range(N - 1):
            ans.append([i+1, N])

        next = [1, 2]
        while totalpath > K:
            ans.append([next[0], next[1]])
            if next == [N - 2, N - 1] and totalpath > K + 1:
                print(-1)
                break
            elif next[1] == N - 1:
                next = [next[0]+ 1, next[0] + 2]
            else: next[1] += 1
            totalpath -= 1
        else:
            print(len(ans))
            for edge in ans:
                print(" ".join(map(str, edge)))

    return 0

if __name__ == "__main__":
    solve()

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

// macros
#define overload_rep(va_0, va_1, va_2, name, ...) name
#define rep_0(i, n) for(int i = 0; i < (n); ++i)
#define rep_1(i, x, y) for(int i = (x); i <= (y); ++i)
#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0)(__VA_ARGS__)
#define all(a) a.begin(), a.end()
#ifndef STOP_DEBUG
#define debug(...)\
    do { cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_cerr(__VA_ARGS__); cerr << noboolalpha; } while (0)
#else
#define debug(...)
#endif

// functions
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
void debug_cerr(){ cerr << '\n'; }
template<class Head, class... Tail>
void debug_cerr(Head head, Tail... tail){
    cerr << ' ' << head;
    debug_cerr(tail...);
}

// cin/cout setup
struct IoSetup{
    IoSetup(){
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} iosetup;

// libraries

// declarations

// solve
int main(){

    string S;
    cin >> S;
    if(S == "SUN")cout << "7\n";
    if(S == "MON")cout << "6\n"; 
    if(S == "TUE")cout << "5\n"; 
    if(S == "WED")cout << "4\n"; 
    if(S == "THU")cout << "3\n"; 
    if(S == "FRI")cout << "2\n"; 
    if(S == "SAT")cout << "1\n"; 

}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int f[4][4];
int main()
{
    int a,b,c;
    scanf("%d%d%d",&f[1][1],&f[1][2],&f[2][2]); a=f[2][2]*3;
    f[1][3]=a-f[1][1]-f[1][2];
    f[3][1]=a-f[1][3]-f[2][2];
    f[3][3]=a-f[1][1]-f[2][2];
    f[2][1]=a-f[1][1]-f[3][1];
    f[2][3]=a-f[2][1]-f[2][2];
    f[3][2]=a-f[1][2]-f[2][2];
    for(int i=1;i<=3;i++)
    {
        for(int j=1;j<=3;j++)
            printf("%d ",f[i][j]);
        printf("\n");
    }
    return 0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0;
};
;
;
;
;
;
;
;

Measured memory_bytes: 128
# coding: utf-8
import itertools
s='%d%s%d%s%d%s%d'
a,b,c,d=map(int,input())
for n in itertools.permutations(('+++---'),3):
    ans=s%(a,n[0],b,n[1],c,n[2],d)
    if eval(ans)==7:
        print(ans+'=7')
        break

Measured memory_bytes: 3188
// Iterative Deepening
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<string>
#include<cassert>
using namespace std;
#define N 4
#define N2 16
#define LIMIT 100

static const int dx[4] = {0, -1, 0, 1};
static const int dy[4] = {1, 0, -1, 0};
static const char dir[4] = {'r', 'u', 'l', 'd'};
int MDT[N2][N2];

struct Puzzle { int f[N2], space, MD; };

Puzzle state;
int limit;  /* 深さの制限 */
int path[LIMIT];

int getAllMD(Puzzle pz) {
  int sum = 0;
  for ( int i = 0; i < N2; i++ ) {
    if ( pz.f[i] == N2 ) continue;
    sum += MDT[i][pz.f[i] - 1];
  }
  return sum;
}

bool isSolved() {
  for ( int i = 0; i < N2; i++ ) if ( state.f[i] != i + 1 ) return false;
  return true;
}


bool dfs(int depth, int prev) {
  if ( state.MD == 0 ) return true;
  /* 現在の深さにヒューリスティックを足して制限を超えたら枝を刈る */
  if ( depth + state.MD > limit ) return false;

  int sx = state.space / N;
  int sy = state.space % N;
  Puzzle tmp;

  for ( int r = 0; r < 4; r++ ) {
    int tx = sx + dx[r];
    int ty = sy + dy[r];
    if ( tx < 0 || ty < 0 || tx >= N || ty >= N ) continue;
    if ( max(prev, r)-min(prev, r) == 2 ) continue;
    tmp = state;
    /* マンハッタン距離の差分を計算しつつ、ピースをスワップ */
    state.MD -= MDT[tx * N + ty][state.f[tx * N + ty] - 1];
    state.MD += MDT[sx * N + sy][state.f[tx * N + ty] - 1];
    swap(state.f[tx * N + ty], state.f[sx * N + sy]);
    state.space = tx * N + ty;
    if ( dfs(depth + 1, r) ) { path[depth] = r; return true; }
    state = tmp;
  }

  return false;
}

/* 反復深化 */
string iterative_deepening(Puzzle in) {
  in.MD = getAllMD(in);  /* 初期状態のマンハッタン距離 */

  for ( limit = in.MD; limit <= LIMIT; limit++ ) {
    state = in;
    if ( dfs(0, -100) ) {
      string ans = "";
      for ( int i = 0; i < limit; i++ ) ans += dir[path[i]];
      return ans;
    }
  }

  return "unsolvable";
}

int main() {
  for ( int i = 0; i < N2; i++ )
    for ( int j = 0; j < N2; j++ )
      MDT[i][j] = abs(i / N - j / N) + abs(i % N - j % N);

  Puzzle in;

  for ( int i = 0; i < N2; i++ ) {
    cin >> in.f[i];
    if ( in.f[i] == 0 ) {
      in.f[i] = N2;
      in.space = i;
    }
  }
  string ans = iterative_deepening(in);
  cout << ans.size() << endl;

  return 0;
}


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

h= list(map(int,input().split()))

ab = [map(int, input().split()) for _ in range(m)]
a, b = [list(i) for i in zip(*ab)]

#print(a)

ans=[0]*n
cot=0
t=0
s=0
for i in range(m):
    t=a[i]
    s=b[i]
    if h[t-1]>h[s-1]:
        ans[s-1]=1
    elif h[t-1]<h[s-1]:
        ans[t-1]=1
    else :
        ans[s-1]=1
        ans[t-1]=1
for e in range(n):
    if ans[e]==0:
        cot+=1
#print(ans)
print(cot)


Measured memory_bytes: 67020
s=str(input())
k=int(input())
t=s*2

ans=0
a=1
for i in range(len(s)-1):
    if s[i]==s[i+1]:
        a+=1
    else:
        ans+=a//2
        a=1
ans+=a//2
#print(ans,ans*k)

ans_=0
a_=1
for i in range(len(t)-1):
    if t[i]==t[i+1]:
        a_+=1
    else:
        ans_+=a_//2
        a_=1
ans_+=a_//2
#print(ans_)
if len(set(s))!=1:
    print(ans+(k-1)*(ans_-ans))
elif k%2==0:
    print(ans+(k-1)*(ans_-ans))
else:
    print((k//2)*(len(s))+(k%2)*(len(s)//2))


Measured memory_bytes: 3064
#include <iostream>
//#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1
//#define INFTY 1000000000000000000

int main(){
    LL a;
    LL b;
    LL c;
    LL d;
    cin >> a >> b >> c >> d;
    if(a+b>c+d){
        cout << "Left" << endl;
    }else if(a+b==c+d){
        cout << "Balanced" << endl;
    }else{
        cout << "Right" << endl;
    }

    return 0;
}


Measured memory_bytes: 3620
H,W=map(int,input().split())
lc=[]
for i in range(10):
    lc.append(list(map(int,input().split())))
la=[]
for i in range(H):
    la.append(list(map(int,input().split())))
for k in range(10):
    for i in range(10):
        for j in range(10):
            lc[i][j]=min(lc[i][j],lc[i][k]+lc[k][j])
ans=0
for i in range(H):
    for j in range(W):
        if la[i][j]!=-1:
            ans+=lc[la[i][j]][1]
print(ans)


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

using namespace std;
typedef long long ll;
const ll mx = 10000007;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
#define    ss   second
#define    ff   first
#define    pb   push_back
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
#define FIO ios_base::sync_with_stdio(false);  cin.tie(NULL);


int main() {
    FIO;
    string s, t;
    cin >> s >> t;
    for (ll i = 0; i < t.size() - 1; i++) {
        if(s[i] != t[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}



Measured memory_bytes: 3580
#include <stdio.h>
#include <stdlib.h>   

int main()
{
int sum,i=0;
 char str[1000];
  while(1){
        scanf("%s",&str);
        if (str[0]=='0')break;
        sum=0;
        for (i=0;str[i]!='\0'; i++) {
            sum+=(str[i]-'0');
        }
        printf("%d\n",sum);
        }

 return 0;
}

Measured memory_bytes: 536
#include<iostream>
#include<string>
using namespace std;
int main()
{
    string str;
    cin >> str;
    if(str == "SSS"){
        cout << 0 << endl;
    }
    else if(str == "RRR"){
        cout << 3 << endl;
    }
    else if(str == "RRS" || str == "SRR"){
        cout << 2 << endl;
    }
    else if(str == "RSS" || str == "SRS" || str == "SSR"|| str == "RSR"){
        cout << 1 << endl;
    }
}


Measured memory_bytes: 3548
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

#define rep(i,n) for (int i = 0; i < n; ++i)
#define REP(i,k,n) for (i = k; i <= n; ++i)
#define REPR(i,k,n) for (int i = k; i >= n; --i)

#define LSOne(S) (S & (-S))
#define isBitSet(S, i) ((S >> i) & 1)

int max_n = 1e6 + 1;

void solve() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll a1 =  max(d * b, c * a);
    ll a2 = max(d * a, c * b);
    cout << max(a1, a2);
}

//#define LOCAL 1

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

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    solve();

    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
using namespace std;

int main() {
    int h, n;
    int count = 0;
    cin >> h >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
        count += a.at(i);
    }
    if (h <= count) {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}


Measured memory_bytes: 640
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
using ar26 = array<int, 26>;

template<typename T>
class SegmentTree {
private:
    using F = function<T(T, T)>; // モノイド型
    int n; // 横幅
    F f;   // モノイド
    T e;   // モノイド単位元
    vector<T> data;

public:
    // init忘れに注意
    SegmentTree() {}
    SegmentTree(F f, T e) :f(f), e(e) {}
    void init(int n_) {
        n = 1;
        while (n < n_)n <<= 1;
        data.assign(n << 1, e);
    }
    void build(const vector<T>& v) {
        int n_ = v.size();
        init(n_);
        rep(i, n_)data[n + i] = v[i];
        for (int i = n - 1; i >= 0; i--) {
            data[i] = f(data[(i << 1) | 0], data[(i << 1) | 1]);
        }
    }
    void set_val(int idx, T val) {
        idx += n;
        data[idx] = val;
        while (idx >>= 1) {
            data[idx] = f(data[(idx << 1) | 0], data[(idx << 1) | 1]);
        }
    }
    T query(int a, int b) {
        // [a,b)
        T vl = e, vr = e;
        for (int l = a + n, r = b + n; l < r; l >>= 1, r >>= 1) {
            if (l & 1)vl = f(vl, data[l++]); // unknown
            if (r & 1)vr = f(data[--r], vr); // unknown
        }
        return f(vl, vr);
    }
};

int main()
{
    int N, Q;
    string S;
    cin >> N >> S >> Q;
    vector<ar26> alcnts(N, ar26());
    rep(i, N) {
        alcnts[i][S[i] - 'a']++;
    }
    auto f = [](ar26 l, ar26 r) {rep(i, 26)l[i] += r[i]; return l; };
    ar26 e;
    rep(i, 26)e[i] = 0;
    SegmentTree<ar26> seg(f, e);
    seg.build(alcnts);
    rep(q, Q) {
        int com;
        cin >> com;
        if (com == 1) {
            int i;
            char c;
            cin >> i >> c;
            i--;
            auto next = e;
            next[c - 'a']++;
            seg.set_val(i, next);
        }
        else {
            int l, r;
            cin >> l >> r;
            l--; r--;
            auto res = seg.query(l, r + 1);
            int cnt = 0;
            for (auto num : res)if (num > 0)cnt++;
            cout << cnt << endl;
        }
    }

    return 0;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) {
    cin >> a[i];
    a[i] -= (i + 1);
  }

  sort(all(a));
  int m = a[n / 2];

  ll ans = 0;
  rep(i, n) ans += abs(a[i] - m);
  cout << ans << endl;
}


Measured memory_bytes: 1024
"""

https://atcoder.jp/contests/agc035/tasks/agc035_c

全ての対の頂点に関して、パス上の重みのxorが自分に等しい
1から順に求めていくことを考える

A,Bの関係を考える
木なので、片方のパス上にあればいい→片方にのみ含ませることも、両方に含ませることも可能

1をいい感じに使って構築できないか？

101-100-1-101-100
みたいに、1の位だけ違う数字をまとめて処理すればいい感じになる
もう一つの1は、どっかの葉につけておけばおk
これで、Nが奇数かつ1でない場合は全て構築可能！！

偶数の時は？ 2,4みたいな場合は自明にダメ
6は？
001 010 011 100 101 110
xorで110になるのは010と100

101-100-1-010-011
    |     |
    110   100

→分からんけどとりあえず提出

偶数でも可能な場合がある…
(N+i)-(N+i+1)- -(i)-(i+1)
とする

"""
import sys
N = int(input())

if N == 1:
    print ("No")

elif N % 2 == 1:
    print ("Yes")

    for i in range(2,N+1,2):
        print (1,i)
        print (i,i+1)
        print (1,i+1+N)
        print (i+1+N,i+N)

    print (N+1,3)

else:

    a = None
    b = None

    for i in range(1,N):
        if N ^ i < N:
            a = i
            b = N ^ i

    if a == None:
        print ("No")
        sys.exit()
    
    print ("Yes")
    for i in range(2,N,2):
        print (i,i+1)
        print (N+i,N+i+1)

        #1につけていく
        if i not in (a,b) and i+1 not in (a,b):
            print (1,i)
            print (1,N+i+1)

    pa = a^1
    pb = b^1

    #print ("===")

    print (N+1,a)
    print (a,b)
    print (N,a)
    print (b,2*N)
    print (1,pa)

    print (1,a+N)
    print (pa+N,pb+N)
    
    
    
        
        


Measured memory_bytes: 77056
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	var tmp int
	for i:=0; i<N; i++ {
		fmt.Scan(&tmp)
		if(tmp%2 == 0) {
			if(tmp%3 != 0 && tmp%5 != 0) {
				fmt.Println("DENIED")
				return
			}
		}
	}
	fmt.Println("APPROVED")
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <memory.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <queue>
#pragma comment(linker, "/STACK:1000000000")
using namespace std;
typedef long long LL;
typedef double D;

struct node
{
	int val, pos;
};

struct type
{
	int from, to;
 	node data;
};

class Compare
{
public:
	bool operator()(type a, type b)
	{
		return a.data.val > b.data.val;
	}
};

priority_queue<type, vector<type>, Compare> q;

const int N = 2e5 + 2, inf = 1e9;
node arr[2][N << 1];

node MIN(node a, node b)
{
	return a.val < b.val ? a : b;
}

node min_q(int l, int r)
{
	bool c = l & 1;
	node res = {inf, -1};
	for (l += N, r += N; l < r; l >>= 1, r >>= 1)
	{
		if (l & 1) res = MIN(res, arr[c][l++]);
		if (r & 1) res = MIN(res, arr[c][--r]);
	}
	return res;
}

int main()
{
	ios::sync_with_stdio(0);
	int n;
	cin >> n;
	memset(arr, 1, sizeof(arr));
	for (int i = 0; i < n; ++i)
	{
		arr[0][N + i].pos = arr[1][N + i].pos = i;
		cin >> arr[i & 1][N + i].val;
	}
	
	for (int i = N - 1; i > 0; --i)
	{
		arr[0][i] = MIN(arr[0][i << 1], arr[0][i << 1 ^ 1]);
		arr[1][i] = MIN(arr[1][i << 1], arr[1][i << 1 ^ 1]);
	}
	
	q.push({0, n, min_q(0, n)});
	
	while (!q.empty())
	{
		type v = q.top();
		q.pop();
		
		node a = v.data, b = min_q(a.pos + 1, v.to);
		cout << a.val << ' ' << b.val << ' ';
		
		if (a.pos - v.from >= 2)
			q.push({v.from, a.pos, min_q(v.from, a.pos)});
		if (b.pos - a.pos > 2)
			q.push({a.pos + 1, b.pos, min_q(a.pos + 1, b.pos)});
		if (v.to - b.pos > 2)
			q.push({b.pos + 1, v.to, min_q(b.pos + 1, v.to)});
	}
}

Measured memory_bytes: 8564
import Data.List
import Data.List.Split
import Data.Bool

readInt :: String -> Int
readInt = read

main = do
 s <- map readInt.wordsBy(=='/')<$>getLine
 putStrLn $ bool "TBD" "Heisei" $ solve s

solve :: [Int] -> Bool
solve [year,month,day]
 | year > 2019 = False
 | year < 2019 = True
 | month > 4 = False
 | otherwise = True

Measured memory_bytes: 508
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner io = new Scanner(System.in);
		int N = io.nextInt();
		int T = io.nextInt();
		int prv = -T;
		int now = 0;
		int ans = 0;
		for (int i = 0; i < N; i++) {
			now = io.nextInt();
			ans += Math.min(now-prv, T);
			prv = now;
		}
		System.out.println(ans);
		
	}
}

Measured memory_bytes: 62344
#include <cstdio>
#include <cstdlib>

int compar(const void *a, const void *b)
{
    return *(int *)a - *(int *)b;
}

int main()
{
    int color[3], N;
    scanf("%d %d %d %d", &color[0], &color[1], &color[2], &N);
    qsort(color, 3, sizeof(int), compar);
    int count = 0;
    int maxi = N/color[0];
    for(int i=0; i<=maxi; i++){
        int N1 = N - color[0] * i;
        int maxj = N1/color[1];
        for(int j=0; j<=maxj; j++){
            int N2 = N1 - color[1] * j;
            if(N2 % color[2] == 0)
                count++;
        }
    }
    printf("%d\n", count);
}


Measured memory_bytes: 128
#include<cstdio>
#include<unordered_map>
#define abs(x) ((x)<0? -(x):(x))
#define min(a,b) ((a)<(b)? (a):(b))
typedef long long ll;
std::unordered_map<ll,bool> vis;
int main() {
	ll n,k,minn=1e18+5;
	scanf("%lld%lld",&n,&k);
	while(!vis[n]) {
		vis[n]=1;
		if(n<k) n=abs(n-k);
		else n=abs(n%k); 
		minn=min(minn,n);
	}
	printf("%lld",minn);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int A[1000000], n;

int binarySearch(int key)
{
	int left = 0;
	int right = n;
	int mid;

	while (left < right)
	{
		mid = (left + right) / 2;
		if (key == A[mid]) return 1;
		if (key > A[mid]) left = mid + 1;
		else if (key < A[mid]) right = mid;
	}
	return 0;
}

int main()
{
	int i, q, k, sum = 0;

	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &A[i]);
	}

	scanf("%d", &q);
	for (int i = 0; i < q; i++)
	{
		scanf("%d", &k);
		if (binarySearch(k)) sum++;
	}

	printf("%d\n", sum);
	return 0;
}


Measured memory_bytes: 2100
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <string>
#include <utility>
#include <map>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pint;
typedef map<int,int> mint;
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
int inf=1e9+10;
ll infi =1e18+1;

int N;
ll a[200100];

int main() {
	cin>>N;
	Rep(i,N) cin>>a[i];
	ll sum=0;
	Rep(i,N) sum+=a[i];
	ll c[N+1];
	c[0]=0;
	ll d =infi;
	Rep(i,N-1){
		c[i+1]=c[i]+a[i];
		ll e = abs(sum-c[i+1]-c[i+1]);
		if(e<d){
			d=e;
		}
	}
	cout<<d<<endl;

	return 0;
}

Measured memory_bytes: 3328
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
#include <cmath>
using namespace std;

const int MOD = 1e9 + 7;

const int N = 5000001;
long long fact[N];
long long invfact[N];
long long inv[N];
void init() {
        fact[0] = fact[1] = 1;
        for (int i = 2; i < N; i ++) fact[i] = fact[i - 1] * i % MOD;
        inv[1] = 1;
        for (int i = 2; i < N; i ++) inv[i] = (MOD - MOD / i) * inv[MOD % i] % MOD;
        invfact[0] = invfact[1] = 1;
        for (int i = 2; i < N; i ++) invfact[i] = invfact[i - 1] * inv[i] % MOD;
}
long long C(long long n, long long r) {
        if (r == 0) return 1;
        if (n < 0 || r < 0 || n < r) return 0;
        return fact[n] * invfact[n - r] % MOD * invfact[r] % MOD;
}

int main() {
        init();
        int n;
        scanf("%d", &n);
        long long ans = fact[n];
        for (int k = 1; k <= n - 1; k ++) {
                ans -= C(k - 1, n - 1 - k) * fact[k] % MOD * fact[n - 1 - k] % MOD;
                cerr << ans << endl;
                if (ans < 0) ans += MOD;
        }
        printf("%lld\n", ans);
        return 0;
}


Measured memory_bytes: 117376
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;
//using System.Numerics;
using static System.Math;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 };
    readonly int mod = 1000000007;
    readonly string alfa = "abcdefghijklmnopqrstuvwxyz";
    readonly string ALFA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

    int N;
    List<int>[] G;
    void solve()
    {
        N = cin.nextint;
        G = Enumerable.Range(0, N).Select(i => new List<int>()).ToArray();
        for (int i = 0; i < N - 1; i++)
        {
            int x = cin.nextint - 1;
            int y = cin.nextint - 1;
            G[x].Add(y);
            G[y].Add(x);
        }
        int ret = calc(0, -1);
        WriteLine(ret == 0 ? "Bob" : "Alice");
    }
    int calc(int u, int par)
    {
        int xor = 0;
        foreach (var v in G[u])
        {
            if (v == par) continue;
            xor ^= (calc(v, u) + 1);
        }
        return xor;
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 39568
#include <stdio.h>

int calc(int y, int m, int d) {
    int x = 0;
    if (y % 3 == 0 || m % 2 != 0)
	x = 21 - d;
    else
	x = 20 - d;
    for (int i = m + 1; i < 11; i++) {
	if (y % 3 == 0 || i % 2 != 0)
	    x += 20;
	else
	    x += 19;
    }
    for (int i = y + 1; i < 1000; i++) {
	if (i % 3 == 0)
	    x += 200;
	else
	    x += 195;
    }
    return x;
}

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

    for (int i = 0; i < n; i++) {
	int y, m, d;
	scanf("%d%d%d", &y, &m, &d);
	printf("%d\n", calc(y, m, d));
    }
    return 0;
}

Measured memory_bytes: 1752
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define PB push_back
#define MP make_pair
#define endl '\n'
#define pri 1000000007
#define all(x) x.begin(),x.end()
#define mnx 1000001
#define pr pair<ll,ll>
using namespace std;
#define dsz 100001

ll dsu[dsz];
ll si[dsz];
void sdsu(){for(ll i=0;i<dsz;i++){dsu[i]=i;si[i]=1;}}
ll root(ll a){
          	if(dsu[a]==a)return a;
          	else return dsu[a]=root(dsu[a]);
          }
void join(ll x,ll y){
          	ll x1=root(x);
          	ll x2=root(y);
          	if(x1==x2)return;
          	if(si[x1]<si[x2])swap(x1,x2);
          	si[x1]+=si[x2];
          	dsu[x2]=x1;
          }
void masterstroke(){
	
	ll n,x,y;
	cin>>n;
	
	sdsu();
	ll sz[100001]={0};
	vector <ll> ya[100001];
	vector <ll> xa[100001];
	for(ll i=0;i<n;i++){
		cin>>x>>y;
		ya[y].PB(x);
		xa[x].PB(y);
		sz[x]++;		}

	ll ans=0;
	for(ll i=1;i<100001;i++){
		if(int(ya[i].size())==0)continue;
		ll siz=int(ya[i].size());
		ll un=0,x;
		for(auto j:ya[i]){
			if(un==0){x=root(j);un=1;continue;}
	    	join(j,x);
			x=root(j);}
							}
set <ll> ass[100001];							
for(ll i=1;i<100001;i++){
	for(auto j:xa[i]){
	if(ass[root(i)].find(j)==ass[root(i)].end())
	{   ans+=si[root(i)];
		ass[root(i)].insert(j);}}
}
ans-=n;

cout<<ans<<endl;

}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++)masterstroke();
}


Measured memory_bytes: 17152
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	
	fmt.Println(int(math.Pow(float64(n), 3)))
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i, x) for (long long i = 0; i < x; i++)
#define repn(i, x) for (long long i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())
vector<pair<string, P> > vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long A, long long B, long long C, long long X, long long Y) {
    cout << min(min(A * X + B * Y, (X - min(X, Y)) * A + (Y - min(X, Y)) * B +
                                       min(X, Y) * 2 * C),
                max(X, Y) * 2 * C)
         << endl;
}

int main() {
    long long Y;
    long long C;
    long long A;
    long long X;
    long long B;
    scanf("%lld", &A);
    scanf("%lld", &B);
    scanf("%lld", &C);
    scanf("%lld", &X);
    scanf("%lld", &Y);
    solve(A, B, C, X, Y);
    return 0;
}


Measured memory_bytes: 256
/*
    なせば大抵なんとかなる！
*/

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <limits.h>
#include <float.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iterator>
#include <vector>
#include <map>
#include <utility>
#define LLU unsigned long long int
#define LL long long int
#define LD long double
using namespace std;
#define Lfmax DBL_MAX
#define LLUmax ULLONG_MAX
#define LLmax LLONG_MAX
#define dmax INT_MAX
#define vd vector<int>
#define vLL vector<long long int>
#define vLLU vector<unsigned long long int>
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define debug printf("asd\n")
#define debugd(a) printf("--%d\n",a)
#define debugdd(a,b) printf("--%d %d\n",a,b)
#define debugarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i]);printf("\n")
#define newline printf("\n")
#define forin(a,b,c) for(int a=b ; a<c ; a++)
#define forde(a,b,c) for(int a=b ; a>=c ; a--)
#define UPC(oo) (a>='A' && a<='Z')
#define LWC(oo) (a>='a' && a<='z')

inline void scd(int &a){scanf("%d",&a);}
inline void scdd(int &a,int &b){scanf("%d %d",&a,&b);}
inline void sctd(int &a,int &b,int &c){scanf("%d %d %d",&a,&b,&c);}
inline void sctlld(LL &a,LL &b,LL &c){scanf("%I64d %I64d %I64d",&a,&b,&c);}
inline void scdlld(LL &a,LL &b){scanf("%I64d %I64d",&a,&b);}
inline void sclld(LL &a){scanf("%I64d",&a);}

inline void prd(int a){printf("%d",a);};
inline void prdd(int a,int b){printf("%d %d",a,b);};
inline void prtd(int a, int b, int c){printf("%d %d %d",a,b,c);};
inline void prtlld(LL a, LL b, LL c){printf("%I64d %I64d %I64d",a,b,c);};
inline void prdlld(LL a, LL b){printf("%I64d %I64d",a,b);};
inline void prtlld(LL a){printf("%I64d",a);};

#define scarrd(a,b) for(int index=0 ; index<b ; index++)scanf("%d",&a[index])
#define prarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i])
#define iniarr(a,b) for(int i=0 ; i<b ;i++)a[i]=0
#define arr(a,b) int *a=(int *)malloc(b*sizeof(int))
#define llarr(a,b) long long int *a=(long long int *)malloc(b*sizeof(long long int))
#define st(a,b) char *a=(char *)malloc(b*sizeof(char))
#define grav 9.8
#define pi 3.14159265

int main()
{
	char a[200000],b[200000];
	scanf("%s %s",a,b);
	int len=strlen(a);
	int lenb=strlen(b);
	if(len<lenb)
	{
		printf("LESS\n");
		return 0;
	}
	else if(len>lenb)
	{
		printf("GREATER\n");
		return 0;
	}
	
	for(int i=0 ; i<len ; i++)
	{
		if(a[i]>b[i])
		{
			printf("GREATER\n");
			return 0;
		}
		else if(a[i]<b[i])
		{
			printf("LESS\n");
			return 0;
		}
	}
	printf("EQUAL\n");
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
   int x,y,z;
   int a,b,c;
   scanf("%d %d %d", &x, &y, &z);

   a = z;
   b = x;
   c = y;

   printf("%d %d %d\n", a, b, c);

   return 0;
}


Measured memory_bytes: 1704
N = int(input())
*A, = map(int, input().split())
dic = {}
ans = 0
for a in A:
    if a in dic:
        dic[a] += 1
    else:
        dic[a] = 1
for k, v in dic.items():
    if k == v:
        continue
    elif k > v:
        ans += v
    else:
        ans += v - k
print(ans)


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

#define mp       make_pair
#define mt	  make_tuple
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF=1<<29;
const double EPS=1e-9;
const ll MOD = 1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
const int MAX_N = 1010;
struct edge{//エッジの定義
  int tar;//目的地
  double ecost;//辺のコスト
  edge(){}
  edge(int tar, double ecost):tar(tar),ecost(ecost){
  }
};
struct State{//状態の定義
  int pos;//現在地
  double cost;//スタートからposまでのコスト
  State(){}
  State(int _pos, double _cost){
    pos = _pos;
    cost = _cost;
  }
  //costが大きい物ほど小さいと定義priority_queueがdefault昇順のため
  bool operator < (const State &st) const {
    return cost > st.cost;
  }
};
vector<edge> edges[MAX_N];//隣接リスト
double dist[MAX_N];//始点sから頂点dist[v]までの最短コスト
void dijkstra(int s){
  priority_queue<State> que;
  for (int i = 0; i < MAX_N; i++){
    dist[i] = 1e40;
  }
  dist[s] = 0;
  que.push(State(s, 0));
  while (!que.empty()){
    State p = que.top();
    que.pop();
    if (dist[p.pos] < p.cost)continue;
    for (int i = 0; i < edges[p.pos].size(); i++){
      edge e = edges[p.pos][i];
      if (dist[e.tar] > dist[p.pos] + e.ecost){
	dist[e.tar] = dist[p.pos] + e.ecost;
	que.push(State(e.tar, dist[e.tar]));
      }
    }
  }
  return ;
}
ll sy,sx;
ll ty,tx;
int N;
vector<tuple<ll, ll, ll>> yx;

double barrier_dist(double py, double px, double pr, double qy, double qx, double qr){
  double res1 = sqrt((py - qy) * (py - qy) + (px - qx) * (px - qx));
  double r12 = pr + qr;
  //cout << res1 << " " << r12 << endl;
  if (res1  < r12){
    return 0;
  }
  return res1 - r12;
}
int main(){
  cin >> sx >> sy >> tx >> ty;
  yx.emplace_back(mt(sy, sx, 0));//0
  cin >> N;
  for (int i = 0; i < N; i++){
    int y,x,r;
    cin >> x >> y >> r;
    yx.emplace_back(mt(y, x, r));
  }
  yx.emplace_back(mt(ty, tx, 0));// N + 2
  
  for (int i = 0; i < N + 2; i++){
    for (int j = i + 1; j < N + 2; j++){
      //cerr << i << " " << j << endl;
      double py,px,pr;
      tie(py, px, pr) = yx[i];
      double qy,qx,qr;
      tie(qy, qx, qr) = yx[j];
      double dist = barrier_dist(py, px, pr, qy, qx, qr);
      //cerr << i << " " << j << " " << dist << endl;
      edges[i].push_back(edge(j, dist));
      edges[j].push_back(edge(i, dist));
    }
  }
  dijkstra(0);
  // for (int i = 0; i < N + 2; i++){
  //   //cout << dist[i] << endl;
  // }
  double ans = dist[N + 1];
  printf("%.20lf\n", ans);
  return 0;
}


Measured memory_bytes: 20720
#include<bits/stdc++.h>
using namespace std;
char a[101];
char b[101];
int main()
{
    while(scanf("%s%s",&a,&b)!=EOF){
        int la=strlen(a);
        int lb=strlen(b);
        sort(a,a+la);
        sort(b,b+lb);
        if(a[0]<b[lb-1]) cout<<"Yes"<<endl;
        else if(a[0]>b[lb-1]) cout<<"No"<<endl;
        else{
            if(a[0]==a[la-1]&&b[0]==b[lb-1]&&a[0]==b[0]){
                if(lb>la) cout<<"Yes"<<endl;
                else cout<<"No"<<endl;
                continue;
            }
            int k=0;
            for(int i=0;i<la;i++){
                for(int j=0;j<lb;j++){
                    if(b[j]>a[i]){
                        k++;
                        break;
                    }
                }
            }
            if(k==la) cout<<"Yes"<<endl;
            else cout<<"No"<<endl;
        }
    }
    return 0;
}

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

using namespace std;

#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define LL long long
#define ULL unsigned long long
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<LL,int>
#define PLL pair<LL,LL>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<LL,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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






int main()
{
    FAST();
    int n;
    cin >> n;
    cout << n+n*n+n*n*n;
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
//useful library
int long long gcd(int long long a, int long long b){
    return b?gcd(b,a%b):a;
} //最大公約数
int long long lcm(int long long a, int long long b){
    return a/gcd(a,b)*b;
} //最小公倍数
int long long GetDigit(int long long num){
    int long long digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
} //桁数
int long long GetDigitN(int long long num, int long long N){
    int long long digit=0;
    while(num!=0){
        num /= N;
        digit++;
    }
    return digit;
} //十進数でnumの際のN進数における桁数

int main(){
    int a, b; //a 匹 b 足
    cin >> a >> b;
    bool c = false;
    for(int i = 0; i <= a; i++){
        if(2*i + 4*round(a-i) == b){
            c = true;
            break;
        }
    }
    if(c == true){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
using namespace std;
int main()
{
int a,b,c;
int cont1=0;
int cont2=0;
cin>>a>>b>>c;
if(a==5)
cont1++;
else if(a==7)
cont2++;
if(b==5)
cont1++;
else if(b==7)
cont2++;
if(c==5)
cont1++;
else if(c==7)
cont2++;
if(cont1==2 && cont2==1)
{
cout<<"YES"<<endl;
}
else
{
cout<<"NO"<<endl;
}
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
using namespace std;
vector<char> aleft(15);
int main(){
  aleft[0]='q'; aleft[1]='w'; aleft[2]='e'; aleft[3]='r'; aleft[4]='t';
  aleft[5]='a'; aleft[6]='s'; aleft[7]='d'; aleft[8]='f'; aleft[9]='g';
  aleft[10]='z'; aleft[11]='x'; aleft[12]='c'; aleft[13]='v'; aleft[14]='b';
  char str[64];
  while(scanf("%s", str) && str[0] != '#'){
    bool f = 0;
    int res = 0;
    if(find(aleft.begin(), aleft.end(), str[0]) == aleft.end()) f = 1;
    REP(i, 1, strlen(str)){
      if((find(aleft.begin(), aleft.end(), str[i]) == aleft.end()) != f){ res++; f = (f+1)%2;}
    }

    printf("%d\n", res);
  }
  return 0;
}

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


using namespace std;

const int maxi=1e6+2;

long long a[maxi];
int n;
int ans;
vector<int> v[maxi];

int main()
{
    cin>>n;

    for (int i=1;i<=n;i++)
        scanf("%lld",&a[i]);

       sort(a+1,a+n+1);
       reverse(a+1,a+n+1);

       int uzet=0;
       int tot=0;
       long long ans1=1;

      for (int i=2;i<=n;i++)
        if (uzet!=i-1 && tot<2 && a[i]==a[i-1] )
        {
            uzet=i;
            tot++;
            ans1*=a[i];
        }

        if (tot==2) printf("%lld\n",ans1); else printf("0\n");

  return 0;
}


Measured memory_bytes: 24832
#include <iostream>
#include <algorithm>
#include<vector>
#include <queue>
using namespace std;
int main()
{
	long a, b;
	long ans = 0;
	cin >> a >> b;
	if (a > 1 && b > 1)ans = (a - 2)*(b - 2) ;
	else if (a == 1 && b == 1)ans = 1;
	else ans = max(a,b)-2;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> d(N);
  for(int i=0;i<N;i++){
    cin >> d[i];
  }
  sort(d.begin(),d.end());
  cout << d[N/2]-d[N/2-1] << endl;
}

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

int main() {
	string s;
	cin >> s;
	int t;
	bool b=true;
	char c['{']={};
	for (int i=0;i<s.length();i++){
		c[s[i]]++;
	}
	for (char q='a';q<='z';q++){
		if (c[q]>1){
			b=false;
		}
	}
	if (b) {
		cout << "yes";
	}else{
		cout << "no";
	}
	return 0;
}

Measured memory_bytes: 256
/*author : Yashvardhan
Sunday, May 10, 2020
5:26 PM
*/

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

using ll = long long;

#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define mp make_pair
#define endl '\n'
#define all(a) a.begin(), a.end()
#define initialise(a, x) memset(a, x, sizeof(a))
#define rev(Y) reverse(all(Y))

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define debug(...)
#endif

template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;} 
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;} 
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}

const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;

int takemod(int a){return ((a%mod)+mod)%mod;}

int pow(int a, int b, int m)
{
	int ans = 1;
	a %= m;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}

int modinv(int a){return takemod( pow( takemod(a), mod-2,mod ) );}


signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	#ifdef __APPLE__
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif

	time_t t1, t2;
	t1 = clock();
	
	string s,t;
	cin >> s >> t;

	bool flag = true;
	for(int i = 0; i < s.size(); i++){
		flag &= (s[i] == t[i]);
	}

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

	t2 = clock();
	cerr << endl << t2-t1 << endl;
	
	return 0;
}



Measured memory_bytes: 3676
#include<bits/stdc++.h>
#define _USE_MATH_DEFINES
using namespace std;
 
#define ll long long int
#define pb push_back
#define rep(i , j , n) for(ll i = j ; i < n ; i++)
#define per(i , j , n) for(ll i = j ; i >= n ; i--)
#define all(x) x.begin(), x.end()
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vll;

vector<vector<char>> a;
vector<vector<ll>> dist,vis;

int main(){
    ll n,m,k,x1,y1,x2,y2;
    cin >> n >> m >> k >> x1 >> y1 >> x2 >> y2;
    a = vector<vector<char>> (n + 1, vector<char> (m + 1));
	vis = dist = vector<vector<ll>> (n + 1, vector<ll>(m + 1, 0));
    rep(i,1,n + 1){
        rep(j,1,m + 1){
            cin >> a[i][j];
        }
    }
    queue<pair<ll,ll>> q;
    q.push({x1,y1});
    ll dirx[] = {0,0,1,-1};
    ll diry[] = {1,-1,0,0};
    dist[x1][y1] = 0;
    vis[x1][y1] = 1;
    while(!q.empty()){
        ll x0 = q.front().first;
        ll y0 = q.front().second;
        q.pop();
        rep(i,0,4){
            rep(j,1,k + 1){
                ll nx = x0 + j*dirx[i];
                ll ny = y0 + j*diry[i];
                if(nx > n || nx < 1 || ny > m || ny < 1) break;
                if(a[nx][ny] == '@') break;
                if(vis[nx][ny] && dist[x0][y0] + 1 > dist[nx][ny]) break;
                if(vis[nx][ny]) continue;

                vis[nx][ny] = 1;
                dist[nx][ny] = dist[x0][y0] + 1;
                q.push({nx,ny});
                if(nx == x2 && ny == y2){
                    cout << dist[x2][y2];
                    return 0;
                }
            }
        }
    }
    cout << -1 << endl;


}


Measured memory_bytes: 44316