akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());
 
signed main()
{   
    gearup;
    int n; cin >> n;

    out(0);
    string ze; cin >> ze;
    if(ze == "Vacant")return 0;

    ll mi = 1,ma = n;
    while(1){
        ll mid = (ma+mi)/2;
        out(mid);
        //fflush(stdout);

        string res; cin >> res;
        if(res == "Vacant"){
            return 0;
        }
        else if(mid % 2 == 0){ //0からの距離s
            if(res == ze)mi = mid;
            else ma = mid;
        }
        else {
            if(res == ze)ma = mid;
            else mi = mid;
        }
    }
    return 0;
}

Measured memory_bytes: 3808
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

const int MAX_N=4001;
const int mod=1000000007;
ll fact[MAX_N+1];
ll inv[MAX_N+1],finv[MAX_N+1];
int inv_init(ll n,ll p){
    inv[1]=1;
    FOR(i,2,n+1) inv[i]=p-(p/i)*inv[p%i]%p;
    fact[0]=finv[0]=1;
    FOR(i,1,n+1){
        fact[i]=fact[i-1]*i%p;
        finv[i]=finv[i-1]*inv[i]%p;
    }
    return 0;
}
ll comb_mod(ll n,ll k,ll p){
    if(k<0||n<k) return 0;
    return finv[k]*finv[n-k]%p*fact[n]%p;
}
int main(){
    int n,k;
    cin>>n>>k;
    inv_init(n*2,mod);
    FOR(i,1,k+1){
        ll ans=comb_mod(n-k+1,i,mod)*comb_mod(k-i+i-1,k-i,mod);
        cout<<ans%mod<<endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <set>
#include <utility>
using namespace std;

int main() {
  int N; cin >> N;
  int a[110];
  for (int i = 0; i < N; i++)
    cin >> a[i];
  int c = 0;
  int p = 1;
  while (p < N) {
    if (a[p-1] == a[p]) {
      c++;
      p++;
    }
    p++;
  }
  cout << c << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
  int main()
{	
    ll n;
    cin>>n;
    ll a[n],b[n+1],c[n];
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
    }
    b[1]=abs(a[0]-a[1]);
    b[2]=min(abs(a[0]-a[1])+abs(a[2]-a[1]),abs(a[0]-a[2]));
    for(ll i=3;i<n;i++) 
    {
        b[i]=min(abs(a[i-1]-a[i])+b[i-1],b[i-2]+abs(a[i-2]-a[i]));
    }   
    cout<<b[n-1];
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; i++)
const long long MOD = 1000000007;

int main(){
    ll N; cin >> N;
    ll a;
    ll sum = 0;
    rep(i,N){
        cin >> a;
        sum += a;
    }
    cout << sum - N << endl;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

using namespace std;

typedef long long ll ;
typedef double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector< pair<int,int> > vii;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define mp			make_pair
#define fi			 first
#define se			 second
#define for0(i,n)        for(int i=0;i<n;i++)
#define for1(i,n)        for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
//#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)    cout<<"Case "<<z<<": "<<x<<"\n"
bool valid(db n){
	if(ceil(n) == floor(n)) return 1;
	return 0;
	}
int sq(int a){
	return a*a;
	}
int main()
{
	int i,j,k,n,d,x,c=0;
	cin>>n>>d;
	vi a[n+1];
	for0(i,n){
		for0(j,d){
			cin>>x;
			a[i].pb(x);
			}
		}
	db p;
	for0(i,n-1){
		for(j=i+1 ; j<n ; j++){
			int s=0;
			for0(k,d){
				s += sq(a[i][k] - a[j][k]);
				}
			p = (db)sqrt((db)s);
			if(valid(p)) c++;
			}
		}
	cout<<c<<nw;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
long long int mod = 998244353;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<ll> G[100005];
vector<P> tree[100010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
//↓,→,↑,←
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
	//aのb乗を計算する
	if(bed==0){return 1;}
	else{
		ll ced = rui(abc,bed/2);
		ced *= ced;
		ced %= mod;
		if(bed%2==1){ced*=abc; ced%=mod;}
		return ced;
	}
} 

ll i,j,k,ii,jj;
ll n,m,num,sumxor,sum,ans;
ll a,b,c,d,e,f,g,h,w,v,p;
string s[500005];
string t;
ll x[800005],y[800005],z[900005];
ll dp[5000][5000];


int main(){	
	cin>>k>>n;
	dp[0][0]=1;
	for(i=0;i<=4950;i++){
		for(j=0;j<=i;j++){
			if(i==j || j==0){
				dp[i][j]=1;
			}else{
				dp[i][j] = dp[i-1][j] + dp[i-1][j-1];
				dp[i][j] %= mod;
			}
		}
	}
	//dp[i][j] := i C j
	for(i=2;i<=2*k;i++){
		ans = 0;
		if(i%2==1){
			if(i<=k){
				p = i/2;
			}else{
				p = (2*k+2-i)/2;
			}
			for(j=0;j<=p;j++){
				//p個のpairのうちj個には何にもない
				g = k - p - j;
				//出していい目がg個
				num = dp[p][j];
				if(g<=0)continue;
				ans += (num * dp[n+g-1-p+j][g-1])%mod * rui(2,p-j);
				ans %= mod;
			}
		}else{
			//iが偶数の時
			if(i<=k){
				p = i/2 -1;
			}else{
				p = (2*k+2-i)/2 -1;
			}
			for(j=0;j<=p;j++){
				g = k - p - j;
				//出していい目がg個
				if(g<=1)continue;
				num = dp[p][j];
				
				ans += (num * dp[n+g-2-p+j][g-2])%mod * rui(2,p-j);
				ans %= mod;
				ans += (num * dp[n+g-3-p+j][g-2])%mod * rui(2,p-j);
				ans %= mod;
			}
		}
		p(ans);
	}
	//p(dp[5][-100]);
	return 0;
}

Measured memory_bytes: 203520
import copy
from collections import deque
cnt=0
def dfs(G,s,N,seen):
    global cnt
    li=copy.copy(seen)
    li.append(s)
    if(len(li)==N):
        cnt+=1
        return 0
    for x in G[s]:
        if x in li:
            continue
        dfs(G,x,N,li)
        
N,M=map(int,input().split())
seen=[]
G=[[] for i in range(N)]
for i in range(M):
    a,b=map(lambda x:int(x)-1,input().split())
    G[a].append(b)
    G[b].append(a)
dfs(G,0,N,seen)
print(cnt)

Measured memory_bytes: 3444
#include <iostream>
#include <vector>
#include <algorithm>
#include <experimental/random>

using namespace std;
#ifdef __DEBUG__
    void debug_out() { cerr << endl; } 
    template <typename Head, typename... Tail>
    void debug_out(Head H, Tail... T) {cerr << " " << H; debug_out(T...);}
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 
#endif

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int M;
vector<int> X,Y;
inline void input(){
    fast_io();
    cin >> M;
    X = fetch_vec<int>(M);
    Y = fetch_vec<int>(M);
}
void chmax(int &a, int b){if(a<b) a=b;};

inline int solve(int N, vector<int> A, vector<int> B){
    vector<int> cntA(N+1,0), cntB(N+1,0);
    for(int x:A) cntA[x]++;
    for(int x:B) cntB[x]++;
    for (int i = 1; i <= N; i++)
    {
        if((cntA[i]+cntB[i])>N){
            cout << "No" << "\n";
            return 0; 
        }
    }
    vector<int> IA = cntA, IB = cntB;
    for (int i = 0; i < N; i++)
    {
        IA[i+1] += IA[i];
        IB[i+1] += IB[i];
    }

    int x = 0;
    for (int k = 1; k <= N; k++)
    {
        if(cntA[k]==0 || cntB[k]==0) continue;
        chmax(x, IA[k]-IB[k-1]);
    }
    
    cout << "Yes" << "\n";
    // xだけBをずらす.
    for (int i = 0; i < N; i++)
    {
        cout << B[(N+i-x)%N];
        if(i!=N-1) cout << " ";
    }
    cout << "\n";
    

    return 0;
}   



int test(){
    int n = 5;
    vector<int> a(n);
    vector<int> b(n);
    for (int i = 0; i < n; i++)
    {
        a[i] = std::experimental::randint(1, n);
        b[i] = std::experimental::randint(1, n);
    }
    sort(a.begin(),a.end());    
    sort(b.begin(),b.end());

    debug(n);
    debug(a);
    debug(b);
    solve(n, a, b);
    return 0;
}

int main()
{
    // int t = 10;
    // while(t--) test();
    input();
    solve(M,X,Y);
    return 0;
}


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

int main() {
  int r,g,b;
  cin >> r >> g >> b;

  int c = 100*r + 10*g + b;
  if(c % 4 == 0){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
      
    
}


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

int main(){
  int n; 
  cin>>n;
  set<int> d;

  for(int i=0; i<n; i++){
    int a;
    cin >> a;
    d.insert(a);
  }

  cout << d.size() << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, k; cin >> n >> k;
    string s; cin >> s;
    s[k-1]=tolower(s[k-1]);
    cout << s << endl;
}
//g++ -o proa.exe proa.cpp

//VSCなら./test
//Atomならtest.exe


Measured memory_bytes: 256
#pragma GCC target ("avx2,sse2")
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree <int, null_type, less_equal <int>, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long
#define db long double
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define fi first
#define se second
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
//#define endl "\n"

#define left fsdkfsdfsdfd
#define sum dfsdfsdfsdf
#define assign sdkfskdfkk

#define int long long

using namespace std;

void dout() {
    cerr << endl;
}
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;

int bit(signed x) {
    return __builtin_popcount(x);
}
int bit(ll x) {
    return __builtin_popcountll(x);
}

const int N = 5e5 + 7, inf = 1e9;
int n, l[N], r[N], ans;
string s;

void solve(int tc) {
    // check for (int i = 0; i < n; j++)
    cin >> s;
    n = s.size();
    for (int i = 1; i < n + 1; i++) {
        if (s[i - 1] == '<') {
            l[i] = l[i - 1] + (s[i - 1] == '<');
        }
    }
    for (int i = n; i >= 0; i--) {
        if (s[i] == '>') {
            r[i] = r[i + 1] + (s[i] == '>');
        }
    }
    for (int i = 0; i <= n; i++) {
        ans += max(l[i], r[i]);
    }
    cout << ans;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    int tc = 1;
//    cin >> tc;
    for (int i = 0; i < tc; i++) {
        solve(i);
//        cleanup();
    }
}


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

int main(){
  int n,now,j;
cin>>n;
  now=1;
  vector<int>a(n+1);
  for(int i=1;i<n+1;i++){
    cin>>a[i];
  }
  for(int i=1;i<n+10;i++){
    now=a[now];
    j=i;
    if(now==2){
      break;
    }
  }
  if(j>n){
    cout<<-1<<endl;
  }
  else{
    cout<<j<<endl;
  }
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cstdio>
#include <complex>
#include <utility>
#define EPS (1e-10)
#define X real()
#define Y imag()
using namespace std;
typedef complex<double> P;
typedef pair<P,P> L;
typedef vector<P> Poly;

double cross(P a, P b){
  return a.X*b.Y - a.Y*b.X;
}

double area(Poly p){
  int n = p.size();
  double s = 0;
  for(int i = 0; i < n; ++i){
    s -= cross(p[i],p[(i+1)%n])/2;
  }
  return s;
}

int main(){
  int n, c = 0;
  while(cin >> n, n > 0){
    ++c;
    cout << c << " ";
    Poly p;
    double x, y;
    for(int i = 0; i < n; ++i){
      cin >> x >> y;
      p.push_back(P(x,y));
    }
    printf("%.1lf\n",area(p));
  }
  return 0;
}

Measured memory_bytes: 3188
N = int(input())
X = list(map(int, input().split()))
Xsorted = sorted(X)
Xmax = max(X)
Xmin = min(X)
cnt = 0
l = list()

for i in range(Xmin, Xmax + 1):
  for j in range(N):
    cnt += (i - X[j]) ** 2
  l.append(cnt)
  cnt = 0
print(min(l))

Measured memory_bytes: 3060
#include<iostream>
#include<string>

using namespace std;

int main(){
    string s;
    cin >> s;
    for (int i = 0; i < 3; i++)
    {
        if(s[i]==s[i+1])
        {
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String S = sc.next();
    int r = 1;
    char c = S.charAt(0);
    for(int i =1;i<N;i++){
      if(S.charAt(i)!=c){
        c=S.charAt(i);
        r++;
      }
    }
    System.out.println(r);
  }
}

Measured memory_bytes: 30200
class ProcessQueue:
    def __init__(self, N):
        self.MAX = N + 1
        self.Q = [(None, None)] * self.MAX
        self.head = 0
        self.tail = 0

    def isEmpty(self):
        return self.head == self.tail

    def enqueue(self, p):
        self.Q[self.tail] = p
        self.tail += 1
        if self.tail == self.MAX:
            self.tail = 0

    def dequeue(self):
        self.head += 1
        if self.head == self.MAX:
            self.head = 0

        return self.Q[self.head - 1]


N, Q = (int(n) for n in input().split())
processes = ProcessQueue(N)
for i in range(N):
    process = input().split()
    processes.enqueue((process[0], int(process[1])))

time = 0
while not processes.isEmpty():
    process = processes.dequeue()
    if process[1] - Q <= 0:
        time += process[1]
        print(process[0], time)
    else:
        time += Q
        processes.enqueue((process[0], process[1] - Q))



Measured memory_bytes: 13360
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

ll n;

bool poss( ll x ){
	if( x == 1 ) return false;
	ll k = x;
	while( n%k == 0 ){
		k *= x;
	}
	k /= x;
	return (n/k)%x == 1;
}

int main(){
	cin >> n;
	ll ans = 0;
	ll t = n-1;
	for( ll i = 1; i*i <= t; ++i ){
		if( t%i == 0 ){
			if( i*i == t ) ans += 1;
			else ans += 2;
		}
	}
	ans -= 1;
	for( ll k = 2; k*k <= n; ++k ){
		if( n%k == 0 ){
			if( poss(k) ) ++ans;
		}
	}
	ans += 1;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef complex<double> com;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	sort(all(a));
	rep(i, n - 1) a[n - 1] -= a[i];
	if (a[n - 1] < 0) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
from collections import deque
n, m = map(int, input().split())
dat_m = []
for i in range(n + 1):
    dat_m.append(deque([]))

for i in range(m):
    a, b = map(int, input().split())
    dat_m[a].append(b)

c = False
for i in dat_m[1]:
    if n in dat_m[i]:
        c = True

print("POSSIBLE" if c else "IMPOSSIBLE")

Measured memory_bytes: 161164
import sys
input = sys.stdin.readline

memoCou = {}

n = int(input())


def cou(n, s):
    if(memoCou.get((n, s)) != None):
        return memoCou.get((n, s))
    if(not ok(s)):
        return 0
    #print(n, s)
    if(n == 0):
        return 1
    memoCou.update({(n, s): cou(
        n-1, s[1:]+"A")+cou(n-1, s[1:]+"C")+cou(n-1, s[1:]+"G")+cou(n-1, s[1:]+"T")})
    return memoCou.get((n, s))


def ok(s):
    for i in range(4):
        t = list(s)
        if(i < 3):
            t[i], t[i+1] = t[i+1], t[i]
        if("".join(t).count("AGC") >= 1):
            return False
    return True


print(cou(n, "TTTT") % 1000000007)

Measured memory_bytes: 9012
from itertools import product
N = int(input())
cnt = 0
for i in range(3, len(str(N))+1):
    for p in product(["7", "5", "3"], repeat = i):
        if "7" in p and "5" in p and "3" in p:
            n = int("".join(p))
            if n <= N:
                cnt += 1
print(cnt)

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define mem(x, y) memset(x, y, sizeof(x))
#define mp make_pair
#define pb push_back

int main() {
    ll N, M;
    ll A[10001];
    cin >> N >> M;
    for(ll i = 0; i < M; i++) {
        cin >> A[i];
    }

    for(ll i = 0; i < M; i++) {
        N -= A[i];
    }

    if(N < 0) {
        cout << -1 << endl;
    } else {
        cout << N << endl;
    }

    return 0;
}

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

using namespace std;

int main()
{
    
     long long int n;
    cin>>n;
    long long int p=1000000007,ans=0;
     long long int arr[n];
    for(int i=0;i<n;i++)
    {
         cin>>arr[i];
    }
    long long int x=0;
    for(int i=0;i<n;i++)
    {
        ans =(ans + (arr[i] * x)) %p;
         x =(x+arr[i])%p;
         
    }
 
   
   cout<<ans<<endl;
    
	
	return 0;
}


Measured memory_bytes: 5184
#include<bits/stdc++.h>
using namespace std;
#define int long long
int dp[100005][105],arr[102],MOD=1e9+7;

/*int solve(int sum,int n)
{
	if(sum==0)
		return 1;
	if(n==0||sum<0)
		return 0;
	if(dp[sum][n]!=-1)
		return dp[sum][n];
	else
	{
		int temp=0;
		for(int x=0;x<=arr[n];x++)
		{
			if(sum-x>=0)
			temp=((temp%MOD)+(solve(sum-x,n-1)%MOD))%MOD;
		else 
			break;
		}
		dp[sum][n]=temp;
	}
	return dp[sum][n];
}*/
signed main()
{
	int n,k,i,j,x;
	memset(dp,0,sizeof dp);
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>arr[i];
	//cout<<solve(k,n)<<endl;
	for(i=0;i<=n;i++)
		dp[0][i]=1;
	for(i=1;i<=k;i++)
	{
		//for(j=1;j<=n;j++)
			//dp[i-1][j]=((dp[i-1][j]%MOD)+(dp[i-1][j-1]%MOD))%MOD;
		for(j=1;j<=n;j++)
		{
		/*	for(x=0;x<=arr[j];x++)
			{
				if(i-x>=0)
				dp[i][j]+=dp[i-x][j-1];
			}*/
			if(i<=arr[j])
			
				dp[i][j]=dp[i][j-1];
			
			else
				dp[i][j]=((MOD+dp[i][j-1])-(dp[i-arr[j]-1][j-1]))%MOD;
				//dp[i][j]=dp[i][j-1]-dp[i-arr[j]-1][j-1];
				dp[i][j]=(((MOD+dp[i][j])%MOD)+(dp[i-1][j]%MOD))%MOD;

			//dp[i][j]=dp[i][j]+dp[i-1][j];
		}
	}
	
	cout<<dp[k][n]%MOD<<endl;
/*	for(i=0;i<=k;i++)
	{
		for(j=0;j<=n;j++)
			cout<<dp[i][j]<<" ";
		cout<<endl;
	}*/



	return 0;
}

Measured memory_bytes: 82304
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  	int x, L, R, L_, R_;
  	cin >> x >> x >> L >> R; 
  	while (cin >> L_){
      cin >> R_;
      
      if(L_ > L) L = L_;
      if(R_ < R) R = R_;
    }
  
  	if ((R-L + 1) < 1){
    	cout << 0 << endl;
    } else {
  		cout << (R-L +1) << endl;
    }
}

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

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

int main()
{
    int n, k, c = 0;
    long d = 0;
    char dummy;
    scanf("%d %d", &n, &k);
    scanf("%c", &dummy);
    int *h = (int *)malloc(sizeof(int) * n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &h[i]);
    }
    qsort(h, n, sizeof(int), compare_int);
    for (int i = k; i < n; i++)
    {
        d += h[i];
    }
    printf("%ld", d);
    free(h);
    return 0;
}

Measured memory_bytes: 1788
#include<bits/stdc++.h>
 
#define ll long long 
# define skorost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 

using namespace std ;
 
ll z , o , ans ;

ll N = 1e4 + 15820 ;

int main(){ skorost ;

	int k , s ;

	cin >> k >> s ;

	for( int i = 0 ; i <= k ; i ++ ){

		for( int j = 0 ; j <= k ; j ++ ){

			int h = s - ( j + i ) ;

			if( h >= 0 && h <= k ){

				ans ++ ;

			}

		}

	}

	cout << ans << endl ;

}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
#include <cstdint>
using namespace std;
using LL = long long;


int main() {
	int A, B;
	cin >> A >> B;
	if ((A + B) % 2) {
		cout << "IMPOSSIBLE" << endl;
		return 0;
	}
	cout << (A + B) / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
N = input()
ipts = [map(int,raw_input().split(" ")) for i in range(N)]

def solve():
    x,y = 0,0
    pt = 0
    for i in range(N):
        t,nx,ny = ipts[i]
        mv = abs(nx-x) + abs(ny-y)
        mt = t - pt
        
        if mv > mt:
            print "No"
            return
        if (mv - mt)%2:
            print "No"
            return
        x,y = nx,ny
        pt = t

    print "Yes"
            
        

solve()


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

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

vector<pair<ll,int>> factorize(ll n){
  vector<pair<ll,int>> res;
  for(ll i=2;i*i<=n;++i){
    if(n%i) continue;
    res.emplace_back(i,0);
    while(n%i==0){
      n/=i;
      res.back().second++;
    }
  }
  if(n!=1)res.emplace_back(n,1);
  return res;
}

int main(){
  ll a,b;
  cin >>a >> b;
  ll g=gcd(a,b);
  auto f=factorize(g);
  int ans=f.size()+1;
  cout << ans << endl;
  return 0;

}


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

#define read(num) scanf("%d", &num)
#define readll(num) scanf("%lld", &num)
#define read2(num1, num2) scanf("%d%d", &num1, &num2)
#define read3(num1, num2, num3) scanf("%d%d%d", &num1, &num2, &num3)
#define reads(str) scanf("%s", str)
#define readc(ch) scanf("%c", &ch)

#define pb push_back
#define mp make_pair

#define pii pair<int, int>
#define vi vector<int>
#define ll long long

bool cmp(pair<ll,ll>p1,pair<ll,ll>p2){
    if(p1.first>p2.first){
        return true;
    }
    return false;
}
int main()
{
    int n;
    cin>>n;
    ll dp[n+1][n+1];
    memset(dp,0,sizeof(dp));
    vector<pair<ll,ll>>v(n);
    for(int i=0;i<n;i++){
        cin>>v[i].first,v[i].second=i+1;
    }
    sort(v.begin(),v.end(),cmp);
    dp[0][0]=0;
    ll ans=0;
    for(int i=0;i<n;i++){
       // cout<<v[i].first<<" ";
        for(int j=0;j<=i;j++){
            int l=j,r=i-j;
            dp[l+1][r]=max(dp[l+1][r],dp[l][r]+abs(l+1-v[i].second)*v[i].first);
            dp[l][r+1]=max(dp[l][r+1],dp[l][r]+abs(n-r-v[i].second)*v[i].first);
            if(i==n-1){
                ans=max(ans,max(dp[l+1][r],dp[l][r+1]));
               
            }
            // cout<<dp[l+1][r]<<" "<<dp[l][r+1]<<endl;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 34924
#include<bits/stdc++.h>
#define P pair<int,int>
#define fir first
#define sec second
using namespace std;
const int N=1000005;
int q[5],a[N],m,n,Max;
P f[N];
P up(P A,P B)
{
	q[1]=A.fir;q[2]=A.sec;q[3]=B.fir;q[4]=B.sec;
	sort(q+1,q+5);
	return P(q[4],q[3]);
}
int main()
{
	scanf("%d",&m);n=1<<m;
	for (int i=0;i<n;i++) scanf("%d",&f[i].fir);
	for (int i=1;i<n;i<<=1)
	  for (int j=0;j<n;j++)
	    if (!(j&i)) f[j|i]=up(f[j|i],f[j]);
	for (int i=1;i<n;i++)
	  printf("%d\n",Max=max(Max,f[i].fir+f[i].sec));
	return 0;
}

Measured memory_bytes: 9216
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


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

    int n, a, b;

    cin >> n >> a >> b;

    cout << min(n * a, b) << '\n';

    return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>

#pragma warning(disable : 4996)

int N, Y, M, D;

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

	for (int i = 0; i < N; i++)
	{
		scanf("%d", &Y);
		scanf("%d", &M);
		scanf("%d", &D);

		if (Y == 0 && M == 0 && D == 0) break;

		int ret = 0;

		for (int j = 1; j < Y; j++)
		{
			if (j % 3 == 0)
			{
				ret += 200;
			}
			else
			{
				ret += 195;
			}
		}

		for (int j = 1; j < M; j++)
		{
			if (Y % 3 != 0 && j % 2 == 0)
			{
				ret += 19;
			}
			else
			{
				ret += 20;
			}
		}

		ret += D;

		printf("%d\n", 196471 - ret);
	}

	return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-9;
const int inf=1e8;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
	int n;
	cin>>n;
	vp in(n);
	rep(i,n)cin>>in[i].first>>in[i].second;
	ll out=0;
	for(int i=n-1;i>=0;i--){
		ll t=in[i].first+out;
		if(t==0);
		else out+=in[i].second-((t-1)%in[i].second+1);
	}
	cout<<out<<endl;
}










Measured memory_bytes: 1152
#include<cstdio>
#define maxn 100005
#define mod 1000000007
int n,a[maxn],deg[maxn],pre[maxn],cnt[maxn],f[maxn],ans=1;
bool vis[maxn];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) { scanf("%d",&a[i]); deg[a[i]]++; }
	for(int i=1;i<=n;i++)
	{
		if(deg[i]>2) { printf("0\n"); return 0; }
		if(deg[i]<2||vis[i]) continue;
		int p=i;
		do
		{
			if(vis[p]) { printf("0\n"); return 0; }
			vis[p]=true; pre[a[p]]=p,p=a[p];
		}while(p!=i);
	}
	for(int i=1;i<=n;i++)
		if(!deg[i])
		{
			int p=i,l1=0,l2=0;
			while(!vis[p]) vis[p]=true,p=a[p],l1++;
			do l2++,p=pre[p]; while(deg[p]!=2);
			if(l1<l2) ans=ans*2%mod;
			else if(l1>l2) { printf("0\n"); return 0; }
		}
	for(int i=1;i<=n;i++)
		if(!vis[i])
		{
			int p=i,l=0;
			do l++,p=a[p],vis[p]=true; while(p!=i);
			cnt[l]++;
		}
	for(int i=1;i<=n;i++)
	{
		int mul=1;
		if(i!=1&&(i&1)) mul++;
		f[0]=1,f[1]=mul;
		for(int j=2;j<=cnt[i];j++) f[j]=(1ll*f[j-2]*(j-1)%mod*i%mod+1ll*f[j-1]*mul%mod)%mod;
		ans=1ll*ans*f[cnt[i]]%mod;
	}
	printf("%d\n",ans);
}

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int memo = a;
    for(int i = 0;i < b;i++){
        if(memo % b == c){
            cout << "YES" << endl;
            return 0;
        }
        memo += a;
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
#define N 26
#define S 32
int main(void)
{
	int i;
	int c[N]={0};
	char ch;
	while(scanf("%c", &ch) != EOF){
	    if(isalpha(ch)){
			c[(ch-'A')%S]++;
		}
	}
	for(i=0; i<N; i++){
		printf("%c : %d\n", 'a'+i, c[i]);
	}
    return 0;
}

Measured memory_bytes: 544
N,M=map(int,input().split())

fromR = {i:[] for i in range(N+1)}

cnt = [0 for i in range(N+1)]
ans = [-1 for i in range(N+1)]

for _ in range(N-1+M):
    a,b=map(int,input().split())
    fromR[a].append([b,a])
    cnt[b]+=1
r=-1
for i in range(1,N+1):
    if cnt[i]==0:
        r=i
        break

ans[r]=0

que = fromR[r]

while len(que)>0:
    tmp=[]
    for q in que:
        b,a=q
        cnt[b]-=1
        if cnt[b]==0:
            ans[b]=a
            tmp+=fromR[b]
    que=tmp
for a in ans[1:]:
    print(a)


Measured memory_bytes: 81124
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : "\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
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;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

signed main() {
    int N,k;
    cin>>N>>k;
    int x=0;
    REP(i,N-1) {
        int l=0,r=1e18;
        while(r-l>1) {
            int m=(l+r)/2;
            if(m%k==0) {
                m++;
            }
            int y=(m-(m/k+1));
            if(y==x) {
                x=m;
                break;
            }
            else if(y<x) {
                l=m;
            }
            else if(x<y) {
                r=m;
            }
        }
    }
    cout<<x<<endl;
    return 0;
}

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

// repetition
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

// const value
// const ll MOD = 1e9 + 7;
// const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
// const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
inline ll toLL(string s) {
  ll v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, m;
  cin >> n >> m;
  vector<PLL> seq(m);
  rep(i, m) cin >> seq[i].second >> seq[i].first;
  // 区間の終わりが一番早い順
  sort(all(seq));

  ll ans = 0;
  ll lastCut = -1;
  rep(i, m) {
    if(lastCut <= seq[i].second) {
      ans++;
      lastCut = seq[i].first;
    }
  }
  cout << ans << endl;
  return 0;
}


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

const int DIM = 1e5 + 5;

bitset<DIM> oki; deque<long long> deq;

long long axp[DIM], nps[DIM];
long long prm[DIM], pos[DIM], idx[DIM];

int main(void) {
    int n;
    cin >> n;
    
    for (int i = 1; i <= n; ++i) {
        cin >> pos[i];
        
        if (i < n)
            prm[i] = i;
    }
    
    int m; long long k;
    cin >> m >> k; --k;
    
    for (int i = 1; i <= m; ++i) {
        int x;
        cin >> x;
        
        swap(prm[x - 1], prm[x]);
    }
    
    for (int i = 1; i < n; ++i) {
        if (oki[i]) continue;
        
        deq.clear();
        for(int p = i; !oki[p]; p = (int) prm[p])
            idx[deq.size()] = p, oki[p] = true,
            deq.push_back(prm[p]);
        
        int val = (int) (k % deq.size());
        for (int j = 0; j < val; ++j)
            deq.push_back(deq.front()),
            deq.pop_front();
        
        for (int j = 0; j < deq.size(); ++j)
            axp[idx[j]] = deq[j];
    }
    
    nps[1] = pos[1];
    for (int i = 2; i <= n; ++i)
        nps[i] = nps[i - 1] + pos[axp[i - 1] + 1] - pos[axp[i - 1]];
    
    for (int i = 1; i <= n; ++i)
        cout << nps[i] << "\n";
    
    return 0;
}

Measured memory_bytes: 6016
void main() {
    int n = readln.chomp.to!int;
    int[] a = readln.split.to!(int[]);
    auto g = a.sort!"a < b".group.assocArray;
    int cnt;
    foreach (key, val; g) {
        cnt += (val - 1);
    }
    writeln(n - (cnt + 1) / 2 * 2);
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 10300
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

int main() {
    int64_t n;
    cin >> n;

    int32_t prev_t = 0, prev_x = 0, prev_y = 0;
    for (auto i : irange(0L, n)) {
        int32_t t, x, y;
        cin >> t >> x >> y;

        auto dist = abs(x - prev_x) + abs(y - prev_y);
        if (dist > t - prev_t) {
            cout << "No" << endl;
            return 0;
        }

        if (((t - prev_t) - dist) % 2 == 1) {
            cout << "No" << endl;
            return 0;
        }

        prev_t = t;
        prev_x = x;
        prev_y = y;
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<vector>
using namespace std;
int total(int a, int b) {
	int c = 0;
	for (int i = 0; i < b + 1; i++) {
		c += a + i;
	}
	return 0;
}
#define rep(i,n) for(int i=0;i<n;i++)
#define vint(abc,n) vector<int> abc(n);
#define vcha(abc,n) vector<char> abc(n);
#define pi 3.14159265358979323846264338;
int main() {
	int a, b, c;
	int x, y, z;
	cin >> a >> b >> c;
	x = min(min(a, b), c);
	z = max(max(a, b), c);
	if (z == c) {
		y = min(max(a, b), c);
	}
	else {
		y = max(min(a, b), c);
	}
	cout << x << " " << y << " " << z << endl;
	return 0;
}



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

int main(){
  string s;
  cin >> s;
  int t = s.size();
  vector<int>sum(t-2);
  for (int i = 0; i < t-2 ; i++){
    sum.at(i) = (s.at(i) - '0')*100+(s.at(i+1)-'0')*10+s.at(i+2)-'0' ;
    sum.at(i) = abs(sum.at(i) - 753);
  }
  sort(sum.begin(), sum.end());
  cout << sum.at(0);
}
    
    
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll xorsum(ll n){
   bitset<40> b;
   if((n&3)==1||(n&3)==2)
      b.set(0); 
   ll d=1,e=1,f;
   while(n>=d){
      d<<=1;
      f=n&((d<<1)-1);
      if(f>=d && !(f&1))
         b.set(e);
      e++;
   }
   return b.to_ullong();
}
int main() {
  ll a,b;
  cin >> a>>b;
  if(a==b)
    cout<<a;
  else if(a==0)
    cout<<xorsum(b);
  else
    cout<<ll(xorsum(a-1)^xorsum(b));
  return 0;
}

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

// macros
#define int long long 
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define PB push_back
#define MP make_pair
#define bitcount __builtin_popcount
#define watch(x) cerr<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef long double ld;

// template functions
template < typename A, typename B >
ostream& operator << ( ostream& os, const pair< A, B > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "[";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}
template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "{";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}
template < typename A, typename B >
ostream &operator << ( ostream & os, const map< A, B > &v ) {
    os << "[";
    typename map< A, B >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " -> " << it -> second ;
    }
    return os << "]";
}
template <typename T>
inline void printV(vector<T>& a, int n) { for(int i=0; i<n; i++) { cerr<<a[i]<<" "; } cerr<<"\n"; }
template <typename T>
inline void printVV(vector<vector<T>>& a) { for(int i=0; i<sz(a); i++) { cerr<<a[i]<<"\n"; } cerr<<"\n"; }
template <typename T>
inline void clearVV(vector<vector<T>>& a) { for(auto &x : a) { x.clear(); } a.clear(); }
template <typename T>
inline void assignVV(vector<vector<T>> &a, T val) { for(int i=0; i<sz(a); i++) { a[i].assign(sz(a[i]), val); } }
template<typename T>
T gcd(T a, T b) { if(a==0 or b==0) return a+b; return gcd(b, a%b) ; }

// random number generation
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// constants
const long double eps = LDBL_EPSILON;
const int inf = 5e8;
const int modn = 1e9+7;
const int MAX = 1e5;


int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
	int a;
	cin>>a;
	cout<<3*a*a<<"\n";
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int h,w;
    scanf("%d%d", &h,&w);
    char pic[h+2][w+2],c;
    for (int i=1;i<h+1;i++){
        scanf("%c",&c);
        for (int j=1;j<w+1;j++){
            scanf("%c",&pic[i][j]);
        }
    }
    for (int i=0;i<h+2;i++){
        for (int j=0;j<w+2;j++){
            if (i==0 || i==h+1 || j==0 || j==w+1){
                pic[i][j]='#';
            }
            printf("%c",pic[i][j]);
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 128
#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>
#include<random>
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) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    cout << (a & b & 1 ? "Yes" : "No") << '\n';
}


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

typedef long long int ll;

using namespace std;

bool rangeCheck(int num){
	if(num >= 0 && num <= 20)return true;
	else{
		return false;
	}
}

int main(){

	int N;
	cin>>N;

	ll table[N][21];
    vector<int> a(N);
	for(int i = 0; i < N; i++){
		for(int k = 0; k < 21; k++)table[i][k] = 0;
	}

	// ll a[N];
	for(int i = 0; i < N; i++)cin>>a[i];

	table[0][a[0]] = 1;

	for(int i = 1; i < N-1; i++){
		for(int k = 0; k <= 20; k++){
			if(rangeCheck(k-a[i]) == true)table[i][k] += table[i-1][k-a[i]];
			if(rangeCheck(k+a[i]) == true)table[i][k] += table[i-1][k+a[i]];
		}
	}

	printf("%lld\n",table[N-2][a[N-1]]);

    return 0;
}


Measured memory_bytes: 3236
import java.util.*;
public class Main {
    public static void main(String[] args) {
        //data input
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();

        if (A - B * 2 > 0 ) {
            System.out.println(A - B * 2);
        } else {
            System.out.println(0);
        }
    }
}

Measured memory_bytes: 25300
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>
#include <functional>
#include <map>
#include <cstdlib>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;
using Graph = Vvec<int>;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

void bfs(Graph& graph, vector<int>& ans){
    vector<int> vis(graph.size());
    queue<int> q;
    vis[0] = 1;
    q.push(0);
    while(!q.empty()){
        int u = q.front();
        q.pop();
        for(auto& v: graph[u]){
            if(vis[v]) continue;
            vis[v] = true;
            ans[v] = u;
            q.push(v);
        }
    }
}

int main()
{
    int N, M;
    cin >> N >> M;
    Graph graph(N);
    for(int i=0; i<M; i++){
        int u, v;
        cin >> u >> v;
        u--; v--;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }

    vector<int> ans(N);
    bfs(graph, ans);
    cout << "Yes\n";
    for(int i=1; i<N; i++) cout << ans[i]+1 << "\n";
}

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

int main() {
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	//s->t
	vector<char>s, s1;
	if (sx > tx) {
		for (int i = 0; i < sx - tx; i++) {
			cout << 'L';
			s.push_back('L');
		}
	}
	else if (sx < tx) {
		for (int i = 0; i < tx - sx; i++) {
			cout << 'R';
			s.push_back('R');
		}
	}
	if (sy > ty) {
		for (int i = 0; i < sy - ty; i++) {
			cout << 'D';
			s.push_back('D');
		}
	}
	else if (sy < ty) {
		for (int i = 0; i < ty - sy; i++) {
			cout << 'U';
			s.push_back('U');
		}
	}

	//t->s
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'U') {
			cout << 'D';
			s1.push_back('D');
		}
		else if (s[i] == 'D') {
			cout << 'U';
			s1.push_back('U');
		}
		else if (s[i] == 'L') {
			cout << 'R';
			s1.push_back('R');
		}
		else {
			cout << 'L';
			s1.push_back('L');
		}
	}

	//s->t
	if (sy > ty) {
		cout << 'U';
	}
	else {
		cout << 'D';
	}
	if (s[0] == 'R') {
		cout << 'R';
		for (int i = 0; i < s.size(); i++) {
			cout << s[i];
		}
		if (s[s.size()-1] == 'D') {
			cout << 'D';
		}
		else {
			cout << 'U';
		}
		cout << 'L';
	}
	else if (s[0] == 'L') {
		cout << 'L';
		for (int i = 0; i < s.size(); i++) {
			cout << s[i];
		}
		if (s[s.size() - 1] == 'D') {
			cout << 'D';
		}
		else {
			cout << 'U';
		}
		cout << 'R';
	}

	//t->s
	if (sy > ty) {
		cout << 'D';
	}
	else {
		cout << 'U';
	}
	if (s1[0] == 'R') {
		cout << 'R';
		for (int i = 0; i < s1.size(); i++) {
			cout << s1[i];
		}
		if (s1[s1.size() - 1] == 'D') {
			cout << 'D';
		}
		else {
			cout << 'U';
		}
		cout << 'L';
	}
	else if (s1[0] == 'L') {
		cout << 'L';
		for (int i = 0; i < s1.size(); i++) {
			cout << s1[i];
		}
		if (s1[s1.size() - 1] == 'D') {
			cout << 'D';
		}
		else {
			cout << 'U';
		}
		cout << 'R';
	}
	return 0;
}

Measured memory_bytes: 256
#C
from itertools import combinations
H,W,K=map(int,input().split())
C=[input() for i in range(H)]
cnt=0
for i in range(H):
    for j in range(W):
        if C[i][j]=="#":
            cnt+=1
combH=[]
combW=[]
for h in range(H+1):
    combH+=combinations(list(range(H)),h)
for w in range(W+1):
    combW+=combinations(list(range(W)),w)
    
ans=0
for h in combH:
    for w in combW:
        cou=0
        flag=[[True for i in range(W)] for j in range(H)]
        for i in h:
            for j in range(W):
                if flag[i][j]:
                    if C[i][j]=="#":
                        cou+=1
                        flag[i][j]=False
        for i in range(H):
            for j in w:
                if flag[i][j]:
                    if C[i][j]=="#":
                        cou+=1
                        flag[i][j]=False
        if cnt-cou==K:
            ans+=1
print(ans)

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

int main(){
    int n;
    cin>>n;
    vi a(n);
    rep(i,n)cin>>a[i];
    
    sort(a.begin(), a.end());
    cout << a.back()-*a.begin() << endl;
    return 0;
}


Measured memory_bytes: 256