akhauriyash/Code-Regression huggingface dataset:
#pragma region Macros

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

using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
ostream &operator<<(ostream &out, vector<T> const &v) {
    for (auto &&a : v) out << a << " ";
    out << endl;
    return out;
}

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

#pragma endregion

void Main() {
    int D;
    cin >> D;

    vi c(26);
    REP(i, 26) {
        cin >> c[i];
    }
    vector<vector<pair<int, int>>> s(D, vector<pair<int, int>>());
    int buff;
    REP(i, D) {
        REP(j, 26) {
            cin >> buff;
            s[i].push_back({buff, j + 1});
        }
    }

    int count = 0;
    REP(i, D) {
        set<int> set26;
        REP(j, 26) {
            set26.insert(j + 1);
        }
        while (!set26.empty()) {
            vector<pair<int, int>> sss = s[count];
            sort(ALL(sss), greater<pair<int, int>>());
            int a = 1;
            REP(k, 26) {
                if (set26.count(sss[k].second)) {
                    if (rand() % 10 == 0) {
                        continue;
                    }
                    a = sss[k].second;
                    debug(sss[k].second);
                    break;
                }
            }

            cout << a << "\n";
            set26.erase(a);
            debug(a);
            count++;
            if (count >= D) {
                return;
            }
        }
    }
}

#pragma region main
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    cout << flush;
}
#pragma endregion


Measured memory_bytes: 3868
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int ans = 0;
    rep(i, 3) ans += S[i] - '0';
    cout << ans << endl;

    return 0;
}


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

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

template<class T>
inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T>
inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T>
T GCD(T a, T b) { if (b == 0) return a; else return GCD(b, a % b); }
template<class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }
template<class T>
inline T upper(T a, T b) { return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

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

	ll low = 0, high = 0, ans = 0;

	for (int i = 1; i < n + 2; ++i) {
		low += i - 1;
		high += n - i + 1;

		if (i >= k) {
			ans += high - low + 1;
			ans %= mod;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#define  go return 0
#define pb push_back
#include<utility>
#include <algorithm>
#include<iterator>
typedef long long ll;
typedef double db;
#define lp1(i, n)  for(int i=0; i<(int)(n); ++i)
#define lp2(i, n)  for(int i=1; i<=(int)(n); ++i)
#define lp3(j, m)  for(int j=0; j<(int)(m); ++j)
#define all(v)   ((v).begin()), ((v).end())
#define sz(v)    ( (int)((v).size()) )
typedef vector<int> vi;
const int N=1e5+5;
int arr[N];
int main(){

int n,count=0,k;
cin>>n;
string s;
cin>>s;
if (n==1 || n%2!=0)
    cout<<"No";
    else
{
     k=n/2;

    if(s.substr(0,k)==s.substr(k,k))
        cout<<"Yes";
    else
        cout<<"No";
}


go;
}


Measured memory_bytes: 256
def is_prime(x):
    if x == 2:
        return True
    
    if x < 2 or x % 2 == 0:
        return False

    for i in range(3, int(x**0.5)+1, 2):
        if x % i == 0:
            return False
    
    return True


N = int(input())
cnt = 0
for _ in range(N):
    i = int(input())
    cnt += is_prime(i)
print(cnt)

Measured memory_bytes: 7764
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=998244353;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (int i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(int n, int k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}

int main() {
  COMinit();
  ll n; ll a, b, s;
  cin>>n>>a>>b>>s;
  ll ans=0;
  rep(i,n+1) {
    ll r = s-a*i;
    if (r%b) continue;
    ll j = r/b;
    if(j>n) continue;
    ll tmp = COM(n,i)*COM(n,j)%MOD;
    ans+=tmp;
    ans%=MOD;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 27072
#include<bits/stdc++.h>
#include<string.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1<<29;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

ll a[200002];

int main() {

	ll n;

	cin>>n;

	rep(i,n){
		cin>>a[i];
		a[i]-=i+1;
	}
	sort(a,a+n);
	ll total=0;
	rep(i,n){
		total+=abs(a[i]-a[n/2]);
	}
	cout<<total<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main() {
  string n, a, b, c, d;
  cin >> n;
  a = n.at(0);
  b = n.at(1);
  c = n.at(2);
  d = n.at(3);
  if (a == b||b == c||c == d) {
    cout << "Bad" << endl;
  }
  else {
   cout << "Good" << endl;
  }
}

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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define ALL(x) (x).begin(), (x).end()
#define BIT(n) (1LL<<(n))
#define SZ(x) ((int)(x).size())
#define fst first
#define snd second
typedef long long ll;
typedef vector<int> vi;typedef vector<vi> vvi;typedef pair<int,int> pii;typedef vector<pii> vpii;

ll dp[51][5001];

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

  dp[0][2500] = 1;

  rep(i, N) {
    int x;
    scanf("%d", &x);
    x -= A;
    rep(s, 5000) if (dp[i][s]) {
      dp[i+1][s] += dp[i][s];
      dp[i+1][s+x] += dp[i][s];
    }
  }
  ll ans = dp[N][2500]-1;
  _p("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 896
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.HashSet;
import java.util.NoSuchElementException;

public class Main {
    private static FastScanner sc = new FastScanner();
    static Node[] V;
    static int[] c;
    static int nowidx;

    public static void main(String[] args) {
    	int n = sc.nextInt();
    	V = new Node[n];
    	for(int i=0; i<n; i++) {
    		V[i] = new Node();
    		V[i].idx = i;
    	}
    	for(int i=0; i<n-1; i++) {
    		int a = sc.nextInt() - 1;
    		int b = sc.nextInt() - 1;
    		V[a].nbr.add(b);
    		V[b].nbr.add(a);
    	}
    	c = new int[n];
    	for(int i=0; i<n; i++) {
    		c[i] = sc.nextInt();
    	}
    	Arrays.sort(c);
    	int max = 0;
    	for(int i=0; i<n-1; i++) {
    		max += c[i];
    	}
    	System.out.println(max);

    	nowidx = n-1;
    	V[0].dfs();
    	StringBuilder sb = new StringBuilder();
    	for(int i=0; i<n; i++) {
    		if(i != 0) sb.append(" ");
    		sb.append(V[i].cnode);
    	}
    	System.out.println(sb);
    }

    static class Node {
    	int idx;
    	int cnode;
        HashSet<Integer> nbr = new HashSet<>();
        boolean vst = false;
        void dfs() {
        	cnode = c[nowidx];
        	nowidx--;
        	vst = true;
        	for(int x : nbr) {
        		if(!V[x].vst) {
        			V[x].dfs();
        		}
        	}
        }
    }

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}


Measured memory_bytes: 29716
def island(w,h,M,i,j):
    q=[(i,j)]
    while len(q)>0:
        cur=q.pop()
        M[cur[0]][cur[1]]=0
        for k1 in range(-1,2):
            for k2 in range(-1,2):
                if 0<=cur[0]+k1<h and 0<=cur[1]+k2<w:
                    if M[cur[0]+k1][cur[1]+k2]==1:
                        q.append(tuple((cur[0]+k1,cur[1]+k2)))


def solve(w,h):
    count=0
    M=[list(map(int,input().split())) for _2 in range(h)]
    for i in range(h):
        for j in range(w):
            if M[i][j]==1:
                count += 1
                island(w,h,M,i,j)
    return count
                

w,h=map(int,input().split())
while(w>0):
    print(solve(w,h))
    w,h=map(int,input().split())


Measured memory_bytes: 5868
use proconio::input;

fn main() {
    const LIMIT: u64 = 1_000_000_000_000_000_000;
    input! {
        n: usize,
        a: [u64; n],
    }
    let ret = a.iter().fold(1u64, |ret, &x| ret.saturating_mul(x));
    if ret > LIMIT {
        println!("-1");
    } else {
        println!("{}", ret);
    }
}


Measured memory_bytes: 4488
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const int maxn = 2e6 + 10;
ll fac[maxn], inv[maxn], facinv[maxn];
ll norm(ll x) { return (x % mod + mod) % mod;}
void pre()
{
	fac[0] = 1; for(int i = 1; i < maxn; ++i) fac[i] = fac[i - 1] * i % mod;
	inv[1] = 1; for(int i = 2; i < maxn; ++i) inv[i] = (mod - mod / i) * inv[mod % i] % mod;
	facinv[0] = 1; for(int i = 1; i < maxn; ++i) facinv[i] = facinv[i - 1] * inv[i] % mod;
}
ll C(int n, int m) { return fac[n] * facinv[m] % mod * facinv[n - m] % mod;};
ll f(int x, int y)
{
	ll ans = 0;
	for(int i = 0; i <= x; ++i) ans = norm(ans + C(i + 1 + y, y));
	return ans;
}
int main()
{
	pre();
	int r1, c1, r2, c2;
	cin >> r1 >> c1 >> r2 >> c2;
	ll ans = f(r2, c2) - f(r1 - 1, c2) - f(r2, c1 - 1) + f(r1 - 1, c1 - 1);
	ans = norm(ans);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 47104
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define mp make_pair
#define S second
#define F first
ll mod=1e9+7;
#define input_from_file  freopen("input.txt", "r", stdin);

int main()
{
  // input_from_file;
  ll n;cin>>n;
  vector< double> vec(n+1,0);
  for(ll i=1;i<=n;i++)   cin>>vec[i];
  vector<vector<double>> dp(2,vector<double>(n+1,0));
  dp[0][0]=1;
  double ans=0;
  // for(ll i=1;i<=n;i++)  dp[i%2][0]=dp[(i-1)%2][0]*(1-vec[i]);
  for(ll i=1;i<=n;i++){
    for(ll j=0;j<=n;j++){
      if(j==0)  {dp[i%2][0]=dp[(i-1)%2][0]*(1-vec[i]);continue;}
      if(i<j) continue;
      dp[i%2][j]=dp[(i-1)%2][j]*(1-vec[i])+dp[(i-1)%2][j-1]*(vec[i]);
      if(i==n && j>n/2)  ans+=dp[i%2][j];
    }
  }
  cout<<setprecision(9)<<ans;
  return 0;

}

Measured memory_bytes: 384
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
using namespace std;
ll n,m,ans=0,x;
int32_t main(){
CODE_START;
cin>>n;
cin>>m;
x=1;
while(x<=n){
    ans++;
    x=x+m;
    x=x+m+1;
}
cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static String[] a;
    static String[] b;
    static String temp;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        a = sc.nextLine().split(" ");
        b = sc.nextLine().split(" ");
        char[] c = {'E','E','E','N','W','W','W','S'};
        boolean flag = false;
        for(int i=0; i<3; i++){
            for(char e:c) {
                    shuffle(e);
                    if(Arrays.equals(a, b)) {
                        flag=true;
                        break;
                    }
            }
        }
        if(flag) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    public static void shuffle(char c) {
        switch (c) {
		case 'E':
			temp = a[0];
			a[0] = a[3];
			a[3] = a[5];
			a[5] = a[2];
			a[2] = temp;
			break;
		case 'N':
			temp = a[0];
			a[0] = a[1];
			a[1] = a[5];
			a[5] = a[4];
			a[4] = temp;
			break;
		case 'W':
			temp = a[0];
			a[0] = a[2];
			a[2] = a[5];
			a[5] = a[3];
			a[3] = temp;
			break;
		default:
			temp = a[0];
			a[0] = a[4];
			a[4] = a[5];
			a[5] = a[1];
			a[1] = temp;
			break;
		}
    }
}



Measured memory_bytes: 26264
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main(){
    long long n,ans=0;
    cin>>n;
    ans+=(n/500)*1000;
    n%=500;
    ans+=n/5*5;
    printf("%lld\n",ans);
    return 0;
}








Measured memory_bytes: 256
H, W = map(int, input().split())
a = [input() for _ in range(H)]
skiph = []
skipw = []
for i in range(H):
    if a[i].count('.') == len(a[i]):
        skiph.append(i)
for i in range(W):
    if a[0][i] == '.':
        for j in range(H):
            if a[j][i] == '#':
                break
        else:
            skipw.append(i)
for i in range(H):
    if i in skiph:
        continue
    for j in range(W):
        if j in skipw:
            continue
        print(a[i][j], end="")
    else:
        print()

Measured memory_bytes: 4468
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=1000010;
const ll mod=1e9+7;

int main(){  
  string s;
  cin >> s;
  int n=s.size();
  int ans=0;
  rep(i,n){
    if(i%2==0&&s[i]=='p'){ans--;}
    if(i%2==1&&s[i]=='g'){ans++;}    
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define ull unsigned long long
#define N 100005
#define mod 1000000007
#define boost ios_base::sync_with_stdio(false);cin.tie(0)
#define prec(n) fixed<<setprecision(n)

#define mii unordered_map<int,int>
#define mll unordered_map<ll,ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi  first

#define se second
#define pb push_back
#define mp make_pair
#define pp pop_back
#define vii vector<int>
#define vll vector<ll>
#define vpp vector<pii>
#define all(c) c.begin(),c.end()
#define tr(it,c) for(it = c.begin() ; it!=c.end() ; it++)
int inf = INT_MAX ;
ll modulo(ll num,ll MOD=mod){ return ((num%MOD)+MOD)%MOD;} // for negative integer
ll power(ll b,ll e,ll MOD=mod){ll ans=1; while(e){if(e%2) ans=(ans*b)%MOD; b=(b*b)%MOD; e/=2;} return ans;}
ll inv(ll num,ll MOD=mod){ return power(modulo(num),MOD-2,MOD); }
ll gcd(ll a,ll b){ return ((b==0) ? a:gcd(b,a%b));}
ll ans[N][105];

int main(){
	boost;
	int n,w;
	cin>>n>>w;
	ll arr[n][2];
	
	for(int i = 0;i<n;i++){
		cin>>arr[i][0]>>arr[i][1];
	}
	
	for(int i = 0;i<=w;i++){
		for(int j = n;j>=0;j--){
			if(i==0){
				ans[i][j] = 0;
			}else if(j==n){
				ans[i][j] = -1e10;
			}else{
				ans[i][j] = max(ans[i][j+1],ans[i-1][j]);
				int k = i - arr[j][0];
				if(k>=0){
					ans[i][j] = max(ans[k][j+1] + arr[j][1],ans[i][j]);
				}
			}
			//cout<<ans[i][j]<<" ";
		}
		//cout<<endl;
	}
	
	cout<<ans[w][0];
	return 0;
}

//Total solved problems:- 13



Measured memory_bytes: 82304
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  ll N = 0,A = 0,B = 0;
  cin >> N;
  vector<ll>v(N);
  rep(i,N){
    cin >> v[i];
  }
  sort(v.begin(), v.end()); //小さい順
  reverse(v.begin(), v.end());
  rep(i,N){
    if(i % 2 == 0){
      A += v[i];
    }
    else{
      B += v[i];
    }
  }
  cout << A - B;
}
        

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = INT32_MAX;
const ll INFL = INT64_MAX;
const int mod = 1e9 + 7;

template <typename T>
void print_vec(vector<T> v) {
  for (T i : v) cout << i << " ";
  cout << endl;
}

int main() {
  int x, y;
  cin >> x >> y;
  if (y < x * 2 || x * 4 < y || y % 2 == 1)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3624
class Node:
    def __init__(self, num, parent, children):
        self.id = num
        self.parent = -1
        self.children = children
        self.depth = 0
        
    def show_info(self):
        print('node {0}: '.format(self.id), end = '')
        print('parent = {0}, '.format(self.parent), end = '')
        print('depth = {0}, '.format(self.depth), end = '')
        if self.children and self.parent != -1:
            print('internal node, ', end = '')
        elif self.parent != -1:
            print('leaf, ', end = '')
        else:
            print('root, ', end = '')
        print(self.children)


def set_node(i_s):
    i_l = list(map(int, i_s.split()))
    num = i_l[0]
    children = i_l[2:]
    node = Node(num, -1, children)
    T[num] = node
    for n in children:
        rn_check_list.remove(n)

def set_pd(node, parent, depth):
    node.parent = parent
    node.depth = depth
    for n in node.children:
        set_pd(T[n], node.id, depth + 1)


import sys

n = int(sys.stdin.readline())

T = [None for i in range(n)]

rn_check_list = [i for i in range(n)]

for x in sys.stdin.readlines():
    set_node(x)

rn_i = rn_check_list[0]

set_pd(T[rn_i], -1, 0)

for n in T:
    n.show_info()

Measured memory_bytes: 55664
inf = 1e10
n = int(input())
h = [int(i) for i in input().split()]
dp = [inf]*n
for i in range(n):
    if i == 0:
        dp[i] = 0
    elif i == 1:
        dp[i] = abs(h[i-1]-h[i])
    else:
        dp[i] = min(dp[i-1]+abs(h[i-1]-h[i]), dp[i-2]+abs(h[i-2]-h[i]))
print(dp[-1])


Measured memory_bytes: 13928
#include <stdio.h>
#define N 100

int main()
{
  int a[N];
  int k,b,v,i,j,n,key;

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

  for(i=1;i<n;i++){
    v = a[i];
    j = i - 1;
      for(b=0;b<n-1;b++){
	printf("%d ",a[b]);
      }
      printf("%d\n",a[b]);
    while(j>=0 && a[j]>v){
      a[j+1] = a[j];
      j--;
      a[j+1] = v;
    }
  }
  for(b=0;b<n-1;b++){
    printf("%d ",a[b]);
  }
  printf("%d\n",a[b]);
  
  return 0;
}

Measured memory_bytes: 2688
import sys
input = sys.stdin.buffer.readline

def main():
    N,A,B,C = map(int,input().split())
    l = [int(input()) for _ in range(N)]
    
    def point(x,y):
        con = len(x)-1
        s = sum(x)
        return con*10+abs(y-s)
    
    ans = 10**8
    for i in range(4**N):
        num = i
        use = []
        base = 1
        bam = [[] for _ in range(4)]
        for j in range(N):
            use.append(num%4)
            num //= 4
        for k in range(N):
            bam[use[k]].append(l[k])
        if len(bam[1])*len(bam[2])*len(bam[3]) == 0:
            continue
        else:
            p = point(bam[1],A)+point(bam[2],B)+point(bam[3],C)
            ans = min(ans,p)

    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
	int A,B;
	cin>>A>>B;
	if (A+B==15){
		cout<<"+"<<endl;
	}else if (A*B==15){
		cout<<"*"<<endl;
	}else{
		cout<<"x"<<endl;
	}
	return 0;
}

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

int main(){
    int N, *x, *y;

    scanf("%d", &N);

    x = (int *) malloc(sizeof(int) * N);
    y = (int *) malloc(sizeof(int) * N);

    for(int i = 0; i < N; i ++){
        scanf("%d%d", x + i, y + i);
    }
    double sum = 0;

    for(int i = 0; i < N - 1; i ++){
        for(int j = i + 1; j < N; j ++){
            sum += sqrt((x[j] - x[i]) * (x[j] - x[i]) + (y[j] - y[i]) * (y[j] - y[i]));
        }
    }
    printf("%lf\n", 2 * sum / N);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String[] date = sc.next().split("/");
		int[] a=new int[3];
		int i=0;
		String ans="TBD";
		for(String str : date) {
			a[i]=Integer.valueOf(str);
			i++;
		}

		if(a[1]<4 || (a[1]==4 && a[2]<=30) ) {
			ans="Heisei";
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 24404
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
using namespace std;


int main(){
    int n, el;
    cin >> n;
    long long k = pow(2, n);
    vector<long long> a(k);
    for(int i = 0; i < k; ++i){
        cin >> a[i];
    }
    sort(a.rbegin(), a.rend());
    vector<long long> an;
    an.push_back(a[0]);
    vector<bool> b(k, false);
    b[0] = true;
    for(int i = 0; i < n; ++i){
        long long s = an.size(), now = 0;
        for(int j = 0; j < s; ++j){
            while(now < k && (b[now] || a[now] >= an[j])) now++;
            if(now == k){
                cout << "No";
                return 0;
            }
            b[now] = true;
            an.push_back(a[now]);
        }
        sort(an.rbegin(), an.rend());
    }

    cout << "Yes";
}


Measured memory_bytes: 4472
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ in >> p.first >> p.second; return in; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

struct Graph{
    struct Node{
        vector<int> dests;
    };
    vector<Node> nodes;
    Graph(int num): nodes(num){ }
    int id(Node* n){ return n - &nodes[0]; }
    int id(Node& n){ return &n - &nodes[0]; }
    void print(){ for(auto& node : nodes){ prints(id(node), node.dests); } }
    void addEdge(int from, int dest){
        nodes[from].dests.push_back(dest);
    }
    void addEdge2(int from, int dest){
        addEdge(from, dest);
        addEdge(dest, from);
    }
    void dfs(vector<int>& maxis, int idx, int from = -1, int depth = 0){
        int cnt = 0;
        for(int didx : nodes[idx].dests){
            if(didx == from){ continue; }
            dfs(maxis, didx, idx, depth + 1);
            cnt++;
        }
        if((int)maxis.size() <= depth){
            maxis.resize(depth + 1);
        }
        maxis[depth] = max(maxis[depth], cnt);
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    Graph g(n);
    vector<pair<int, int>> abs(n - 1); cin >> abs;
    for(int i = 0; i < n - 1; i++){
        g.addEdge2(abs[i].first - 1, abs[i].second - 1);
    }
    ll ans = MLL, mini = MLL;
    auto calc = [&](vector<int>& maxis, int coef){ 
        if((int)maxis.size() <= mini){
            if((int)maxis.size() < mini){
                ans = MLL;
            }
            mini = maxis.size();
            ll cand = coef;
            for(auto& e : maxis){
                cand *= max(1, e);
            }
            printd(ans, cand, maxis);
            ans = min(ans, cand);
        }
    };
    for(int i = 0; i < n; i++){
        vector<int> maxis;
        g.dfs(maxis, i);
        calc(maxis, 1);
    }
    for(int i = 0; i < n - 1; i++){
        vector<int> maxis;
        g.dfs(maxis, abs[i].first - 1, abs[i].second - 1);
        g.dfs(maxis, abs[i].second - 1, abs[i].first - 1);
        calc(maxis, 2);
    }
    cout << mini << ' ' << ans << '\n';
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <queue>
#include <list>
#include <stack>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
 
int main(){
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector< pair<int,int> > v;
  rep(i,N){
    int a;
    cin >> a;
    v.push_back(make_pair(a, i));
  }
 
  v.push_back(make_pair(-2,-1));
  v.push_back(make_pair(-1,N));
  sort(ALLOF(v));
 
  set<int> s;
  
  ll ret = 0;
  rep(i,v.size()){
    ll value = v[i].first;
    int idx = v[i].second;
    if(v[i].first < 0){
      s.insert(idx);
    }else{
      set<int>::iterator it = s.lower_bound(idx);
 
      int ridx = *it;
      it--;
      int lidx = *it;
      ret += (ll)(idx-lidx) * (ll)(ridx-idx) * value;
 
      s.insert(idx);
    }
  }
 
  cout << ret << endl;
  
  return 0;
}

Measured memory_bytes: 11248
#include<iostream>
#include<string>
using namespace std;
int main(){
  bool ok=false;
  char n;
  string s1,s2;
  cin>>s1>>s2;
  int k=0;
  for(int i=0;i<s1.size();i++){
    ok=true;
    for(int t=0;t<s1.size();t++){
      if(s1[t]!=s2[t]) ok=false;
    }
    if(ok) break;
    n=s1[s1.size()-1];
    for(int y=s1.size()-1;y>0;y--)s1[y]=s1[y-1];
    s1[0]=n;
  }
  if(s1.size()!=s2.size()) cout<<"No"<<endl;
  else{if(ok) cout<<"Yes"<<endl;
      else cout<<"No"<<endl;
      }
}

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

int main(void){
   int a, b, c;
   cin >> a;
   cin >> b;
   cin >> c;
   
   if( a < b && b < c ){
   cout << "Yes";
   }else  {
   cout << "No";
   }
   cout << endl;

}


Measured memory_bytes: 3108
n,time = map(int,input().split())
t = list(map(int,input().split()))
stoptime = 0
nagaretime = 0
for i in range(n):
         if nagaretime < t[i]:
                  stoptime += t[i] - nagaretime
         nagaretime = t[i] + time
print(nagaretime - stoptime)



Measured memory_bytes: 26836
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h> //STL include
typedef long long ll;// long long int
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;//namespace

#define dump(x)  cout << #x << " = " << (x) << endl;// debug cout
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;

#define SANKOU(n,a,b) cout << ((n) ? (a) : (b) ) << endl;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)// for macro
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);// warshall-floyd

#define CIN(x) int x;cin>>x;
#define CIN2(x,y) int x,y;cin>>x>>y;
#define CIN3(x,y,z) int x,y,z;cin>>x>>y>>z;
#define SCIN(x) string x;cin>>x;
#define SCIN2(x,y) string x,y;cin>>x>>y;
#define COUT(x) cout<<(x)<<endl;
#define SCOUT(x) cout<<(x)<<" ";
#define ENDL cout<<endl;

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_;
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i];
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl;

#define ALL(obj) (obj).begin(),(obj).end()// iterator

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())


#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define L list<int>

#define pb(a) push_back(a)//push_back
#define mp make_pair// make_pair


int main(){

    CIN(n);
    V front__(3*n);
    VECCIN(front__);
    ll ans=-LINF; // overflow
    priority_queue<int,V,greater<int>> front_;
    priority_queue<int> back_;
    ll fr=0;
    ll ba=0;
    REP(i,n){
        front_.push(front__[i]);
        fr+=front__[i];
        ba+=front__[3*n-i-1];
        back_.push(front__[3*n-i-1]);
    }
    vector<ll> frontsum;
    vector<ll> backsum;
    frontsum.pb(fr);backsum.pb(ba);
    REP(i,n){
        fr+=front__[i+n];ba+=front__[2*n-i-1];
        front_.push(front__[i+n]);
        back_.push(front__[2*n-i-1]);
        fr-=front_.top();ba-=back_.top();
        front_.pop();back_.pop();
        frontsum.pb(fr);backsum.pb(ba);
    }
    reverse(ALL(backsum));
    REP(i,frontsum.size())ans=max(ans,frontsum[i]-backsum[i]);
    COUT(ans);

    return 0;
}


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

int main() {
int l=0,r,x=0,y=0;
string s;
bool f=true;
char c;
cin>>s;
r=s.length()-1;
while(l<=r){
    //cout<<l<<","<<r<<","<<x<<","<<y<<endl;
    if(f){
        if(s[l]=='x'){
            x++;
            
        }else{
            c=s[l];
            f=false;
            
        }
        l++;
    }else{
        if(s[r]=='x'){
            x--;
        }else if(s[r]==c){
            y+=abs(x);
            x=0;
            f=true;
        }else{
            cout<<-1<<endl;
            return 0;
        }
        r--;
    }
}
if(!f)y+=abs(x);
cout<<y<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<P,int>
#define vpp vector<PP>
#define fi first
#define se second
#define INF (1LL<<50)
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
signed main(){
    int n;
    cin>>n;
    vi vec(n*3);
    REP(i,n*3){
        cin>>vec[i];
    }
    int sum=0;
    vi a(n*3);
    priority_queue<int,vi,greater<int>> aq;
    REP(i,n){
        sum+=vec[i];
        aq.push(vec[i]);
    }
    a[n-1]=sum;
    FOR(i,n,n*3){
        int t=aq.top();
        if(vec[i]>t){
            aq.pop();
            aq.push(vec[i]);
            sum+=vec[i];
            sum-=t;
        }
        a[i]=sum;
    }
    REP(i,n*3){
        cerr<<a[i]<<" ";
    }cerr<<endl;
    sum=0;
    priority_queue<int> bq;
    vi b(n*3);
    FOR(i,n*2,n*3){
        sum+=vec[i];
        bq.push(vec[i]);
    }
    b[n*2]=sum;
    REPR(i,n*2-1){
        int t=bq.top();
        if(vec[i]<t){
            bq.pop();
            bq.push(vec[i]);
            sum+=vec[i];
            sum-=t;
        }
        b[i]=sum;
    }
    REP(i,n*3){
        cerr<<b[i]<<" ";
    }cerr<<endl;
    int ans=-INF;
    FOR(i,n-1,n*2){
        ans=max(ans,a[i]-b[i+1]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 9588
#include<stdio.h>
#include<math.h>
 
int main(){
  int ans=0,N,count,K;
  
  scanf("%d %d\n",&N,&K);
  
  int h[N];
  
  for(count=0;count<N;count++){
  scanf("%d ",&h[count]);
  if(h[count]>=K){
     ans=ans+1; 
  }
      
  }
  
printf("%d",ans);  

  
  return 0;
  
}

Measured memory_bytes: 640
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int six[] = new int[6];
		int nine[] = new int[5];
		if (N<6) {
			System.out.println(N);
			return;
		} else if(N<9) {
			System.out.println(N-6+1);
			return;
		}
		six[0] =6;
		nine[0] =9;
		for (int i=1;i<6;i++) {
			six[i] = six[i-1]*6;
		}
		for (int i=1;i<5;i++) {
			nine[i] = nine[i-1]*9;
		}
		Main main= new Main();
		Queue<Money> queue = new ArrayDeque<Money>();
		int count = Integer.MAX_VALUE;
		Money money = main.new Money();
		money.money = N;
		money.count =0;
		queue.add(money);
		while (!queue.isEmpty()) {
			money = queue.poll();
			int sixMax =0;
			for (;sixMax<6;sixMax++) {
				if (six[sixMax]>money.money) {
					break;
				}
			}
			int nowCount = money.count+1;
			int nowMoney = money.money-six[sixMax-1];
			if (nowCount<count) {
				if (nowMoney<6) {
					nowCount +=nowMoney;
					if (nowCount<count) {
						count = nowCount;
					}
				} else if(nowMoney<9) {
					nowCount +=nowMoney-6+1;
					if (nowCount<count) {
						count = nowCount;
					}
				} else {
					Money temp = main.new Money();
					temp.count = nowCount;
					temp.money = nowMoney;
					queue.add(temp);
				}
			}
			int nineMax =0;
			for (;nineMax<5;nineMax++) {
				if (nine[nineMax]>money.money) {
					break;
				}
			}
			nowCount = money.count+1;
			nowMoney = money.money-nine[nineMax-1];
			if (nowCount<count) {
				if (nowMoney<6) {
					nowCount +=nowMoney;
					if (nowCount<count) {
						count = nowCount;
					}
				} else if(nowMoney<9) {
					nowCount +=nowMoney-6+1;
					if (nowCount<count) {
						count = nowCount;
					}
				} else {
					Money temp = main.new Money();
					temp.count = nowCount;
					temp.money = nowMoney;
					queue.add(temp);
				}
			}
		}
		System.out.println(count);
	}

	public class Money {
		int money;
		int count;
	}
}

Measured memory_bytes: 25556
import itertools, sys

N = int(input())
N_list = [i for i in range(1, N+1)]

A = list(map(int, input().split()))
B = list(map(int, input().split()))

if A == B:
    print('0')
    sys.exit()
for v, i  in enumerate(list(itertools.permutations(N_list))):
    i = list(i)
    if A == i:
        a = v
    elif B == i:
        b = v

print(abs(a-b))


Measured memory_bytes: 8052
#include<bits/stdc++.h>
#define f(i,a,b) for(register int i=a;i<=b;++i)
#define ff(i,a,b) for(register int i=a;i>=b;--i)
#define debug(x) cerr << #x << " : " << x << " " << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
const ll mod = 998244353;
const ll mod1 = 2e18 + 7;
const double tiaohe = 0.57721566490153286060651209;
const int inf = 0x3f3f3f3f;
ll oula(ll x) { ll res = x;f(i, 2, x / i) { if (x % i == 0) { res = res / i * (i - 1);while (x % i == 0) x /= i; } }if (x > 1) res = res / x * (x - 1);return res; }
ll quickmod(ll a, ll n, ll m) { ll s = 1;while (n) { if (n & 1) { s = s * a % m; }a = (a*a) % m;n = n / 2; }return s; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
void ex_gcd(ll a, ll b, ll &x, ll &y, ll &d) { if (!b) { d = a, x = 1, y = 0; } else { ex_gcd(b, a % b, y, x, d);y -= x * (a / b); } }
ll inv(ll t, ll p) { ll d, x, y;ex_gcd(t, p, x, y, d);return d == 1 ? (x % p + p) % p : -1; }
//double a = log(n) +tiaohe + 1.0 / (2 * n);
double eqa = (1 + sqrt(5.0)) / 2.0;
const int N = 1e4 + 5;
int t;
int a[N], b[N];
int main()
{
	//freopen("in.txt", "r", stdin);
	int n, x;
	map<int, int> mp;
	cin >> n;
	int fg = 1;
	f(i, 1, n)
	{
		cin >> x;
		if (mp[x] > 0)fg = 0;
		mp[x]++;
	}
	if (fg)puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 12912
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
Int INF = 1e18;
double EPS = 0.00000001;
//Int mod = 1e6+3;

int main() {
    Int n, l;
    cin >> n >> l;
    Int sum = 0;
    Int mi = 1e9;
    for (Int i = 0; i < n; i++) {
        sum += l + i;
        if (abs(mi) > abs(l + i)) {
            mi = l + i;
        }
    }
    dump(sum - mi);
    return 0;
}

Measured memory_bytes: 256
a, b = map(int, input().split())
x = 0
if  a == b:
    print(a)
else:
    if a % 2 == 1:
        x ^= a
        a += 1
    if b % 2 == 0:
        x ^= b
        b -= 1
    num = b - a + 1
    num //= 2
    if num %2 == 1:
        x ^= 1
    print(x)


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,s;
    float t=0,r=0;
    cin>>n;
    while(n--)
    {
        cin>>s;
        r+=1/(float)s;
    }
    cout<<(t+=1/(float)r)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef vector<char> vc;
typedef vector<vector<char> > vvc;
typedef vector<double> vd;
typedef vector<vector<double> > vvd;
template<class T> using vv=vector<vector< T > >;
typedef deque<int> di;
typedef deque<deque<int> > ddi;
typedef deque<bool> db;
typedef deque<deque<bool> > ddb;

// cout pair
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {
  s << p.first << " " << p.second << "\n"; return s;
}

// cout vector<pair>
template<typename T1, typename T2> ostream& operator<<(ostream& s, const vector<pair<T1, T2> >& vp) {
  int len = vp.size(); s << "\n";
  for (int i = 0; i < len; ++i) { s << vp[i]; }
    s << "\n"; return s;
}

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

// cout deque
template<typename T> ostream& operator<<(ostream& s, const deque<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

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

// cout 2-dimentional deque
template<typename T> ostream& operator<<(ostream& s, const deque< deque<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) { s << vv[i]; }
  return s;
}

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  string s;
  cin >> s;
  int all = 0;
  int oversea = 0;
  rep (i, n) {
    if (s[i] == 'c') {
      printf("No\n");
      continue;
    }
    if (all < (a + b)) {
      if (s[i] == 'a') {
        printf("Yes\n");
        all += 1;
        continue;
      } else if (oversea < b) {
        printf("Yes\n");
        all += 1;
        oversea += 1;
        continue;
      }
    }
    printf("No\n");
  }

  return 0;
}


Measured memory_bytes: 1464
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<utility>//pair
#include<list>
#include<vector>//可変長配列
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define all(a) (a).begin(),(a).end()
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>
#define PP pair<ll,ll>
#define F first
#define S second
int dx[8] = { 1,0,-1,0,1,-1,-1,1 };
int dy[8] = { 0,1,0,-1,1,1,-1,-1 };


int n;
map<string, int>t;

int ans;

int main() {
	cin >> n;
	rep(i, n) {
		string s;
		cin >> s;
		t[s]++;
	}
	for (auto it = t.begin(); it != t.end(); it++) {
		ans++;
	}
	cout << ans << endl;

	return 0;
}


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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
constexpr int MOD = 1e9 + 7;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vec>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vec a(n + 1);
    For(i, 1, n) cin >> a[i];

    int total = 0;
    For(i, 1, n) total += a[i];
    total /= 2;

    vec guu(n + 1), ki(n + 1);
    For(i, 1, n) {
        if (i == 1)
            ki[i] = a[i];
        else if (i == 2)
            guu[i] = a[i];
        else if (i % 2 == 0)
            guu[i] += a[i] + guu[i - 2];
        else
            ki[i] += a[i] + ki[i - 2];
    }

    vec v;
    For(i, 1, n) {
        int ans = total;
        if (i - 2 > 0) {
            if (i % 2 == 0)
                ans -= guu[i - 2];
            else
                ans -= ki[i - 2];
        }
        if (i + 1 <= n) {
            if ((i + 1) % 2 == 0)
                ans -= (guu[n - 1] - guu[i - 1]);
            else
                ans -= (ki[n] - ki[i - 1]);
        }
        v.pb(ans * 2);
    }
    print(v);

    return 0;
}


Measured memory_bytes: 5364