akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N; cin>>N;
    vector<int> A(N+2,0);
    int64_t sum=0;
    rep(n,0,N){
        cin>>A.at(n+1);
        sum+=abs(A.at(n+1)-A.at(n));
    }
    sum+=abs(A.at(N+1)-A.at(N));

    rep(n,1,N+1){
        int64_t ans,include,skip;
        include=abs(A.at(n)-A.at(n-1))+abs(A.at(n)-A.at(n+1));
        skip=abs(A.at(n+1)-A.at(n-1));
        
        ans=sum-include+skip;
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 1664
c,d,t,u;
long s;
main()
{
	c=getchar_unlocked();
	while(c-10)
	{
		t+=1;
		d=getchar_unlocked();
		if(c-d)
		{
			s+=(long)t*(t+1)/2;
			if(c=='>')s-=t<u?t:u;
			u=t;
			t=0;
			c=d;
		}
	}
	printf("%ld",s);
}

Measured memory_bytes: 256
#define _DEBUG
#include "bits/stdc++.h"
#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
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	ll A[200001];
	scan(N);
	rep(i,N){
		scan(A[i]);
	}
	ll sum=0;
	ll now=A[0];
	rep1(i,N-1){
		if(A[i]<now){
			sum+=now-A[i];
		}
		else{
			now=A[i];
		}
	}
	prin(sum);
	return 0;
}


Measured memory_bytes: 5196
#include<bits/stdc++.h>
#define max(a,b,c) max(a,max(b,c))
#define min(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF 1145141919

using namespace std;

unsigned long long int factorial(int X){
  int i;
  unsigned long long int res=1;
  for(i=X;i>=2;i--){
    res=(res*i)%MOD;
  }
  return res;
}

int main(void){
  int N,M;
  unsigned long long ans;
  cin >> N >> M;
  if(abs(N-M)>=2){
    cout << "0" << endl;
  }
  else if(N-M==0){
    ans=(factorial(N)*factorial(M)*2)%MOD;
    cout << ans << endl;
  }
  else{
    ans=(factorial(N)*factorial(M))%MOD;
  cout << ans << endl;
  }
}

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

signed main() {
  int n, x, t;
  cin >> n >> x >> t;

  int cnt = 0;
  int ans = 0;
  while(true) {
    cnt += x;
    ans += t;
    if(cnt >= n) {
      break;
    }
  }

  cout << ans << '\n';
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define endl '\n'
#define debug(X) cout << #X << " = " << X << endl

using namespace std;

const long long oo = 1e18;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	#ifdef UTP
	freopen("input.txt", "r", stdin);
	#endif
	int n, m, q; cin >> n >> m >> q;
	vector<long long> a(n), b(m);
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < m; i++) cin >> b[i];
	while (q--) {
		long long x; cin >> x;
		int r1 = upper_bound(a.begin(), a.end(), x) - a.begin();
		int l1 = r1 - 1;
		int r2 = upper_bound(b.begin(), b.end(), x) - b.begin();
		int l2 = r2 - 1;
		long long ans = oo;
		if (l1 >= 0 && l2 >= 0) ans = min(ans, max(x - a[l1], x - b[l2]));
		if (l1 >= 0 && r2 < m) ans = min(ans, b[r2] - a[l1] + min(x - a[l1], b[r2] - x));
		if (l2 >= 0 && r1 < n) ans = min(ans, a[r1] - b[l2] + min(x - b[l2], a[r1] - x));
		if (r1 < n && r2 < m) ans = min(ans, max(a[r1] - x, b[r2] - x));
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <algorithm>
using namespace std;
int main(int argc, const char * argv[]) {
    long A,B,C,X,Y;
    cin>>A>>B>>C>>X>>Y;
    long sum1=0,sum2=0,sum3=0;
    
    if(X>Y){
        sum1+=2*C*Y+ A*(X-Y);
    }else{
        sum1+=2*C*X+ B*(Y-X);
    }
    sum2+=2*C*max(X,Y);
    sum3+=A*X+B*Y;
    cout<<min(min(sum1,sum2),sum3)<<endl;
    return 0;
}


Measured memory_bytes: 256
//Coded by Abhijay Mitra
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <numeric>
#include <vector>
#include <iterator> 
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <cmath>
#include <stack>
#include <cctype>
#include <bitset>
// #include <bits/stdc++.h>
#define double long double
#define int long long int
#define ll int
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define bp __builtin_popcount
#define pb emplace_back
#define koto_memory(a) cout<<(sizeof(a)/1048576.0)<<" MB";
#define res(v) sort(all(v)),v.erase(unique(all(v)), v.end());
#define timer cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
#define deb(x) cout<<"\n["<<#x<<" = "<<x<<"]\n";
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using pii = std::pair<int,int>;
using vpii = std::vector<pii>;
using vvpii = std::vector<vpii>;
#define mp         make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define per(i,b,a) for (int i = b; i >= a; i--)
#define all(x)     x.begin(), x.end()
using namespace std;
const int N=2e6+10;
const int inf = /*0x3f3f3f3f*/1e18+10;
// const ll M = 998244353 ; // Mulo
const int M = 1e9+7 ; // Mulo
const double Pi = 3.14159265;
#define F first
#define S second
int n,sum,S,a[N];
ll sub(ll a,ll b){
  return ((a%M)-(b%M)+M)%M;
}
int mul(int a,int b){
  return ((a)*(b))%M;
}
int add(int a,int b){
  a+=b;
  if(a>=M)a-=M;
  return a;
}
ll powM(ll b, int p) {
  ll r=1;
  for(; p; b=b*b%M, p/=2)
    if(p&1)
      r=r*b%M;
  return r;
}
void solve(){
  cin>>n;
  rep(i,1,n)cin>>a[i],S=add(S,a[i]);
  rep(i,1,n)sum=add(sum,mul(a[i],a[i]));
  // cout<<sub(S,sum);
  // cout<<S-sum;
  cout<<mul(sub(mul(S,S),sum),powM(2,M-2));
}
int32_t main()
{
  ibs;cti;
  solve();return 0;
  /*,cout<<"\n"*/;
  // cout<<"\n";
  int xx=0;
  int t;cin>>t;while(t--){/*xx++;cout<<"Case "<<xx<<":\n"*/;solve();cout<<"\n";}
  return 0;
}

Measured memory_bytes: 5172
#include <bits/stdc++.h>
#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 INF 2e18
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
  
int main()
{
  unsigned long long A, B, C;
  cin >> A >> B >> C;

  unsigned long long MIN = INF;
  unsigned long long sum = A*B*C;

  if(A%2==0||B%2==0||C%2==0){
    cout << 0 << endl;
  }else{
    MIN = min(MIN,A*B);
    MIN = min(MIN,B*C);
    MIN = min(MIN,A*C);
    cout << MIN << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	long long n, k, a = 0, b = 0; cin >> n >> k;
	for (int h = 1; h <= n; h++) {
		if (h%k == 0) { a++; }
		if (h%k == k/2 && k % 2 == 0) { b++; }
	}
	cout <<a*a*a + b*b*b << endl;
	cin >> n;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#define int long long
using namespace std;
char f(char a, char b,char c) {
	if (b == 'W') {
		if (c == 'o')c = 'x';
		else c = 'o';
	}
	if (c == 'o')return a;
	else return (a == 'S' ? 'W' : 'S');
}
signed main() {
	int n; string s; cin >> n >> s;
	string ans = "SS";
	for (int i = 1; i < n - 1; i++) ans += f(ans[i - 1], ans[i], s[i]);
	if (f(ans[n - 2], ans[n - 1], s[n - 1]) == ans[0] && f(ans[n - 1], ans[0], s[0]) == ans[1]) {
		cout << ans << endl; return 0;
	}
	ans = "SW";
	for (int i = 1; i < n - 1; i++) ans += f(ans[i - 1], ans[i], s[i]);
	if (f(ans[n - 2], ans[n - 1], s[n - 1]) == ans[0] && f(ans[n - 1], ans[0], s[0]) == ans[1]) {
		cout << ans << endl; return 0;
	}
	ans = "WS";
	for (int i = 1; i < n - 1; i++) ans += f(ans[i - 1], ans[i], s[i]);
	if (f(ans[n - 2], ans[n - 1], s[n - 1]) == ans[0] && f(ans[n - 1], ans[0], s[0]) == ans[1]) {
		cout << ans << endl; return 0;
	}
	ans = "WW";
	for (int i = 1; i < n - 1; i++) ans += f(ans[i - 1], ans[i], s[i]);
	if (f(ans[n - 2], ans[n - 1], s[n - 1]) == ans[0] && f(ans[n - 1], ans[0], s[0]) == ans[1]) {
		cout << ans << endl; return 0;
	}
	cout << "-1\n";
}

Measured memory_bytes: 640
h,w,a,b = map(int,input().split())
ans1 = [0]*a + [1]*(w-a)
ans2 = [1]*a + [0]*(w-a)
ans = []
for i in range(h):
    if i <= b-1:
        ans.append(ans1)
    else:
        ans.append(ans2)

for i in range(h):
    for j in range(w):
        print(ans[i][j],end='')
    print()

Measured memory_bytes: 6900
s = list(input())
s_set = set(s)

if len(s_set) == 1:
    print("No")
else:
    if s[0] == s[1] and s[2] == s[3]:
        print("Yes")
    elif s[0] == s[2] and s[1] == s[3]:
        print("Yes")
    elif s[0] == s[3] and s[1] == s[2]:
        print("Yes")
    else:
        print("No")

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

int main()
 {
 	int a,b;
 	cin>>a>>b;
 	if(a<10&&b<10)
 		cout<<a*b<<endl;
 	else
 		cout<<"-1"<<endl;
 	return 0;
}
 	
 					

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

using namespace std;

int main(){
string s;
cin >> s;
if(s == "abc"){
    cout <<"Yes";
}
else if(s == "acb"){
    cout <<"Yes";
}
else if(s == "bca"){
    cout <<"Yes";
}
else if(s == "bac"){
    cout <<"Yes";
}
else if(s == "cab"){
    cout <<"Yes";
}
else if(s == "cba"){
    cout <<"Yes";
}
else{
    cout <<"No";
}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define vi vector<int> 
#define vll vector<ll> 
#define pb emplace_back
#define all(x) (x).begin(), (x).end()
#define deb(x) cout << #x << " - " << x << endl;
const ll MOD = 1e9 + 7;
const ll INF = 1<<29;
const ll MAX_N = 1e6 + 7;
using namespace std;

ll x; 

ll power(ll x, ll y) { 
	ll res = 1;
	while (y > 0) { 
		if (y & 1) 
			res = (res*x) ; 
		y = y>>1;
		x = (x*x); 
	} 
	return res; 
}

bool eqn(ll a,ll b){
    ll temp = (a - b) * ( (power(a,4)) + (power(a,3) * b) + (power(a,2) * power(b,2)) + (a * power(b,3)) + (power(b,4)) ) ;
    // if(temp==x) cout << temp;
    if(temp == x) return true;
    else return false;
}

int main() {
    IOS;
    cin >> x;
    vi v;
    for(int i=1;i*i<=x;++i){
        if(x%i==0){
            v.pb(i);
            if(i!=x/i) v.pb(x/i);
        }
    }
    v.pb(x);
    ll got = 0,j;
    for(auto num:v){
        for(int i=-300;i<=300;++i){
            j = num + i;
            if(eqn(j,i)){
                cout << j << " " << i;
                got = 1;
                break;
            } 
        }
        if(got) break;
    }
}

Measured memory_bytes: 3656
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val x = sc.nextInt()
    val dp = Array(1001) { Array(5001) {false} }
    dp[0][0] = true
    for (i in 0 until 1000) {
        for (j in 0 until 5000) {
            if (!dp[i][j]) {
                continue
            }
            dp[i + 1][j] = true
            dp[i + 1][j + 1] = true
            dp[i + 1][j + 2] = true
            dp[i + 1][j + 3] = true
            dp[i + 1][j + 4] = true
            dp[i + 1][j + 5] = true
        }
    }

    for (i in 1..1000) {
        if (i * 100 > x) {
            break
        }
        val rem = x - i * 100
        if (rem <= 5000 && dp[i][rem]) {
            println(1)
            return
        }
    }
    println(0)
}

Measured memory_bytes: 64532
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int K;
    cin >> K;

    int ans = 0;
    ll ct = 7;
    ll md = 0;
    if (K % 2 == 0) {
        cout << -1 << endl;
        return 0;
    }
    while (1) {
        md += ct % K;
        ct *= 10;
        ct %= K;
        ans++;
        if (md % K == 0) break;
        if (ans >= 1e7) {
            ans = -1;
            break;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
import sys

fin = sys.stdin.readline
N, L = [int(elem) for elem in fin().split()]

all_sum = N * (1 + N) / 2 + L * N - N
i = min(max(1, 1 - L), N)
reduce_num = L + i - 1
print(int(all_sum - reduce_num))


Measured memory_bytes: 38256
/* - - - - - - - - - - - - - - -
	User : 		VanishD
	problem :
	Points : 	
- - - - - - - - - - - - - - - */
# include <bits/stdc++.h>
# define 	ll 		long long
using namespace std;
const int inf = 0x3f3f3f3f, INF = 0x7fffffff;
const ll  infll = 0x3f3f3f3f3f3f3f3fll, INFll = 0x7fffffffffffffffll;
int read(){
	int tmp = 0, fh = 1; char ch = getchar();
	while (ch < '0' || ch > '9'){ if (ch == '-') fh = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9'){ tmp = tmp * 10 + ch - '0'; ch = getchar(); }
	return tmp * fh;
}
int main(){
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	int n = read();
	if (n % 2 == 0)
		printf("%d\n", n);
		else printf("%d\n", n * 2); 
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace __gnu_pbds;
using namespace std;
#define testing 1
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << endl
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<endl
#define dbv(v) cerr << #v << ":"; for (auto it : v) cerr << it << ' '; cerr << endl
#define dbvp(v) cerr << #v << ":"; for (auto it : v) cerr << "{"  << it.f << ',' << it.s << "} "; cerr << endl
#define dba(a,ss,ee) cerr << #a << ":"; FOR(i,ss,ee) cerr << a[i] << ' '; cerr << endl
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define inf (int)1e9+500
#define oo (ll)1e18+500
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "LINE: " << __LINE__ << "\n";
typedef pair <int, int> pi;
typedef pair <ll,ll> pl;
typedef pair <pi, int> pii;
typedef tuple<int,int,int> ti3;
string cts(char x) {string t(1,x); return t;}
ll rand(ll a, ll b) { return a + rng() % (b-a+1); }
const int MOD = 1e9 + 7;
template <typename T> void chmax(T& a, T b) {
	a = max(a, b);
}
template <typename T> void chmin(T& a, T b) {
	a = min(a, b);
}
#define MAXN (int)1e5+5
#if !testing
#define cerr if(0)cout
#endif
int R[MAXN], M[MAXN];
int32_t main() {
	IAMSPEED
	int a,b,m; cin>>a>>b>>m;
	FOR(i,1,a)cin>>R[i];
	FOR(i,1,b)cin>>M[i];
	int mn1 = inf, mn2 = inf;
	FOR(i,1,a)chmin(mn1,R[i]);
	FOR(i,1,b)chmin(mn2,M[i]);
	int ans = mn1+mn2;
	FOR(i,1,m) {
		int x,y,c; cin >> x >> y>>c;
		chmin(ans,R[x]+M[y]-c);
	}
	cout<<ans;
}


Measured memory_bytes: 1024
fun main() {
    val (x, n) = readInts()
    val p = if (n == 0) setOf() else readInts().toSet()

    for (i in 0..101) {
        if (!p.contains(x - i)) {
            println(x - i)
            break
        }
        if (!p.contains(x + i)) {
            println(x + i)
            break
        }
    }
}

// Input Reader
private fun readLn() = readLine()!!

private fun readStrings() = readLn().trim().split(" ")
private fun readInts() = readStrings().map { it.toInt() }


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

 int main()
{
   int k,n;
   cin>>k>>n;
   int a[n];
   for(int i=0;i<n;i++){
       cin>>a[i];
   }
   
   sort(a,a+n);
   int maxi=INT_MIN;
   for(int i=0;i<n-1;i++){
       if(abs(a[i]-a[i+1])>maxi){
           maxi=abs(a[i]-a[i+1]);
       }
   }
   int s=a[0]-a[n-1];
   if((a[0]-a[n-1])<0){
      s=s+k;
   }
   maxi=max(maxi,s);
   cout<<k-maxi<<endl;
   
   
   return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int l,r,i,j,ans=1000000000000;
    cin>>l>>r;
    if(r-l>2019)
    {
        cout<<0;
        return 0;
    }
    for(i=l;i<=r;i++)
    {
        for(j=i+1;j<=r;j++)
        {
            ans=min(ans,((i%2019)*(j%2019))%2019);
        }
        if(ans==0)
        break;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<cstring>
using namespace std;
int x[90][90], col[90][90], h, w, c, i, j, k, l, p, q;
queue<int>Q, R;
int main() {
	while (true) {
		c = 0;
        memset(x,0,sizeof(x));
		memset(col, 0, sizeof(col));
		cin >> w >> h;
		if (h == 0) { break; }
		for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { cin >> x[i][j]; } }
		for (i = 0; i < h; i++) {
			for (j = 0; j < w; j++) {
				if (x[i][j] == 1 && col[i][j] == 0) {
					c++;
					col[i][j] = c;
					Q.push(i * 100 + j);
					while (!Q.empty()) {
						while (!Q.empty()) {
							p = Q.front() / 100;
							q = Q.front() % 100;
							for (k = -1; k < 2; k++) {
								for (l = -1; l < 2; l++) {
									if (x[p + k][q + l] == 1 && col[p + k][q + l] == 0) {
										col[p + k][q + l] = c;
										R.push((p + k) * 100 + q + l);
									}
								}
							}
							Q.pop();
						}
						while (!R.empty()) {
							Q.push(R.front());
							R.pop();
						}
					}
				}
			}
		}
		cout << c << endl;
	}
}

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

int main() {
  long long a, b, k;
  cin >> a >> b >> k;
  if ( a <= k ) { k -= a; a = 0; } else { a -= k; k = 0; }
  if ( b <= k ) { b = 0; } else { b -= k; }
  cout << a << ' ' << b << endl;
  return 0;
}


Measured memory_bytes: 3548
#include <bits/stdc++.h>
#define ll long long

using namespace std;

vector<ll> v, dp;
ll c, n, MOD=1e9+7;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n >> c;
    v=vector<ll>(n);
    dp=vector<ll>(c+1, 0);
    dp[0]=1;
    for(ll i=0; i<n; i++){
        cin >> v[i];
        vector<ll> pre(c+1, 0);
        for(ll used=c; used>=0; used--){
            if(used+1<used+min(v[i], c-used)+1){
                pre[used+1]+=dp[used];
                if(used+min(v[i], c-used)+1<=c)
                    pre[used+min(v[i], c-used)+1]-=dp[used];
            }
        }
        ll sum=0;
        for(ll j=0; j<=c; j++){
            sum=(sum+pre[j]+MOD)%MOD;
            dp[j]=(dp[j]+sum)%MOD;
        }
    }
    cout << dp[c] << endl;
	return 0;
}


Measured memory_bytes: 4784
#include<iostream>
using namespace std;
int main(){
  long long i , j  , ans=1e+07;
  cin>>i>>j;
  if((j-i)>=2019) ans=0;
  else{
    for(int h=0;h<(j-i);h++){
      for(int g=0;g<(j-i);g++){
        ans=min(((i+g)*(i+h+1))%2019,ans);
        if(ans==0)break;
    }
      if(ans==0) break;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
using namespace std;
double f(int x[],int y[],int n,int p);
int main(){
	int n;
	cin>>n;
	int v[2][n];
	for(int i=0;i<2;i++){
		for(int j=0;j<n;j++){
			cin>>v[i][j];	
		}
	}
	for(int i=1;i<=3;i++){
		cout<<fixed<<setprecision(5)<<f(v[0],v[1],n,i)<<endl;
	}
	cout<<fixed<<setprecision(5)<<f(v[0],v[1],n,INT_MAX)<<endl;
	return 0;
}

double f(int x[],int y[],int n,int p){
	double D=0;
	if(p!=INT_MAX){
		for(int i=0;i<n;i++){
			D+=pow(abs(x[i]-y[i]),p);
		}
		D=pow(D,1.0/p);
	}else{
		for(int i=0;i<n;i++){
			D=abs(x[i]-y[i])>D?abs(x[i]-y[i]):D;
		}
	}
	return D;
}

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

int main(){
    int m1, d1;
    int m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;

    if(m1 < m2){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }

    return 0;
}




Measured memory_bytes: 384
#include<bits/stdc++.h>
#define lson l, mid, i<<1
#define rson mid+1, r, i<<1|1
#define PII pair<int, int>
#define Size(x) (int)(x.size())
using namespace std;
typedef long long LL;
//const int MOD = 1e9+7;
const auto INF = 0x3f3f3f3f;
const int N = 1e2+5;

int a[N*N];
int ans[N][N];

int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    int k;
    scanf("%d", &k);
    for(int i=1; i<=k; i++) {
        scanf("%d", &a[i]);
    }
    int cnt = 1;
    for(int i=1; i<=n; i++) {
        if(i&1) {
            for(int j=1; j<=m; j++) {
                while(a[cnt] == 0) {
                    cnt++;
                }
                a[cnt]--;
                ans[i][j] = cnt;
            }
        } else {
            for(int j=m; j>=1; j--) {
                while(a[cnt] == 0) {
                    cnt++;
                }
                a[cnt]--;
                ans[i][j] = cnt;
            }
        }
    }
    for(int i=1; i<=n; i++) {
        for(int j=1; j<=m; j++)
            printf("%d%c", ans[i][j], j == m ? '\n' : ' ');
    }
}





Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef  long long  ll;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
typedef pair<ll,ll>pll;
const  ll MAX=100000000;
int main()
{

    ll n;

    cin>>n;



    ll ara[n+23];

    for(ll i=0;i<n;i++)cin>>ara[i];


    ll sum=0;

    ll mn=ara[0];

    for(ll i=1;i<n;i++)
    {
        if(ara[i]<mn)
        {
            sum+=mn-ara[i];

            mn=max(ara[i],mn);
        }
              mn=max(ara[i],mn);

    }



    cout<<sum<<endl;



}



Measured memory_bytes: 5184
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define itn int
#define mod 1000000007
#define INFi 2147483647
#define INFl 9223372036854775807LL
#define fi first
#define se second
#define be begin()
#define en end()
#define re reverse
int abs(int a,int b){
    return max(a,b)-min(a,b);
}
signed main(){
// __builtin_ctz(N); Nを２で何回割り切れるかを返す
//(n+1)*n/2; １からNまでの総和を求める式
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,d=0;
    cin>>a>>b>>c;
    while(true){
	if(c<=0) break;
	d++;
	c-=max(a,b);
    }
    cout<<d<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
typedef  long long ll;
typedef pair<int, int> p;

int dp[10][10];
//vector<vector<int>> dp(10, vector<int>(10));

int main() {
  int N;
  cin >> N;
  ll ans = 0;
  rep(i, 10) rep(j, 10) dp[i][j] = 0;
  for (int i = 1; i < N+1; i++) {
    int back = i % 10;
    int j = i;
    while (j >= 10) {
      j /= 10;
    }
    int top = j;
    dp[top][back]++;
  }
  for (int i = 1; i < 10; i++) {
    for (int j = 1; j < 10; j++) {
      ans += dp[i][j] * dp[j][i];
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3584
import numpy as np

c11, c12, c13 = map(int, input().split())
c21, c22, c23 = map(int, input().split())
c31, c32, c33 = map(int, input().split())
result = 0

b1 = c11
b2 = c12
b3 = c13
a1 = 0
a2 = c21 - b1
a3 = c31 - b1

if(c11 == a1 + b1):
    if(c12 == a1 + b2):
        if(c13 == a1 + b3):
            if(c21 == a2 + b1):
                if(c22 == a2 + b2):
                    if(c23 == a2 + b3):
                        if(c31 == a3 + b1):
                            if(c32 == a3 + b2):
                                if(c33 == a3 + b3):
                                    result = 1
if(result == 1):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 21288
#include<iostream>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<string>
#include<algorithm>
#include<queue>
#define pii pair<int,int>
using namespace std;
int a[200001];
int main(){
  int n;cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
    a[i]-=i+1;
  }
  sort(a,a+n);
  int mid=a[(n-1)/2];
  long long now_sum=0;
  for(int i=0;i<n;i++){
    now_sum+=abs(a[i]-mid);
  }
  cout<<now_sum<<endl;
  return 0;
}

Measured memory_bytes: 1024
S=input()
N=len(S)
for j in range(1,N//2):
    M=N-2*j
    c=0
    for i in range(M//2):
        if S[i]==S[i+M//2]:
            c=c+1
    if c==M//2:
        print(M)
        break
if c==0:
    print(0)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
int main()
{int  x,y,t;

  while(scanf("%d%d",&x,&y)!=EOF)
 { x=abs(x),y=abs(y);
  if(x+y==1)t=1;  
  else
    if( (x%2) && (y%2) )t=x+y-1; 
  else
    if( !(x%2) && !(y%2) )t=x+y;
  else if( x && y) t=x+y;
   else t=x+y+1;
printf("%d\n",t);

}





return 0;}


Measured memory_bytes: 2028
#include <iostream>
#include <vector>
#include <algorithm>

int main(int argc, char const* argv[])
{
    int n, k;
    std::cin >> n >> k;

    auto vec = std::vector<int>(n);

    for(auto &val: vec)
    {
        std::cin >> val;
    }

    std::sort(vec.begin(), vec.end(), std::greater<int>());
    int result = 0;
    for(int i=0;i<k; ++i)
    {
        result += vec[i];
    }
    std::cout << result << std::endl;
}

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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;
const ll MOD = 1000000007;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n, m;
	cin >> n >> m;

	vector<vector<ll>> jobs(m);
	for (int i = 0; i < n; i++) {
		ll a, b;
		cin >> a >> b;

		if (a - 1 >= m) {
			continue;
		}

		jobs[a - 1].push_back(b);
	}

	ll ans = 0;
	priority_queue<ll> pq;
	for (int i = 0; i < m; i++) {
		for (auto yen : jobs[i]) {
			pq.push(yen);
		}

		if (pq.empty()) {
			continue;
		}

		ans += pq.top();
		pq.pop();
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5632
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
#include <stack>
#include <map> // pair
#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
typedef std::stack<int> IntStack;
typedef std::stack<char> charStack;
#define START 0
#define FORWARD 1
#define BACK 2
using namespace std;
using ll = long long;
typedef pair <ll, ll > pll;
//*********************************************************
// 最大公約数（Greatest Common Divisor）を返す。
// 引数に０がある場合は０を返す。
//*********************************************************
ll gcd(ll a, ll b)
{
	ll tmp, r;
	if (a<b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	/* ユークリッドの互除法 */
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
	//// 引数に０がある場合は０を返す
	//if ((0 == m) || (0 == n))
	//	return 0;

	//// ユークリッドの方法
	//while (m != n)
	//{
	//	if (m > n) m = m - n;
	//	else         n = n - m;
	//}
	//return m;
}//gcd
int main()
{
	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	ll n, m, K;
	ll x[100004] = {};
	ll y[100004] = {};
	ll z[100004] = {};
	string s;
	string s1, s2;
	//IntStack yStack;
	//charStack Stack;
	//vector<pair<int, int> > pairs(a);

	cin >> a;
	for (int i = 0; i < a; i++)
	{
		cin >> x[i];
	}
	sort(x, x + a, std::greater<ll>());
	b = x[0];
	for (int i = 1; i < a; i++)
	{
		b = gcd(b, x[i]);
	}
	c = b;
	ans = b;

	b = x[0];
	for (int i = 1; i < a; i++)
	{
		e = gcd(b, x[i]);
		if (d == 0 && e == c)
		{
			d = 1;
		}
		else
		{
			b = e;
		}
	}
	ans = max(b,ans);
	d = 0;
	b = x[a - 1];
	for (int i = 0; i < a - 1; i++)
	{
		e = gcd(b, x[i]);
		if (d == 0 && e == c)
		{
			d = 1;
		}
		else
		{
			b = e;
		}
	}
	ans = max(b, ans);

	d = 0;
	f = x[0];
	x[0] = x[1];
	x[1] = f;
	b = x[0];
	for (int i = 1; i < a; i++)
	{
		e = gcd(b, x[i]);
		if (d == 0 && e == c)
		{
			d = 1;
		}
		else
		{
			b = e;
		}
	}
	ans = max(b, ans);



	cout << ans << endl;



	//cout << ans << endl;

	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;

	return 0;
}
//char型の文字数字は、-'0'で数値に変換できる
//accumulate(x, x + a, 0);//int型までの配列の合計
//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;
//cout << char(z - 'a');
//log10(i) + 1 //10進数の桁数を取得
//
//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}
//
//最小公倍数
//ll x = a * b;
//ll tmp;
///* 自然数 a > b を確認・入替 */
//if (a<b) {
//	tmp = a;
//	a = b;
//	b = tmp;
//}
///* ユークリッドの互除法 */
//ll r = a % b;
//while (r != 0) {
//	a = b;
//	b = r;
//	r = a % b;
//}
//a = x / b;//答え

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  int ans=0;
  for(int i=0;i<n;i++){
    int hi;
    cin>>hi;
    ans+=hi>=k;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3604
N = int(input())
A = list(map(int, input().split()))

ans = [0, 0]
ans_abs = 10**200

A_sum = sum(A)
A_1 = 0
A_2 = A_sum

for i in range(N - 1):
    A_1 += A[i]
    A_2 -= A[i]
    ans_abs = min(ans_abs, abs(A_1 - A_2))

print(ans_abs)

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

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

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<typename T>
void print1(T begin, T end) {
	while (begin != end) {
		cerr << (*begin) << " ";
		*begin++;
	}
	cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
	for (int i = 0; i < height; i++) {
		for (int j = 0; j < width; j++) {
			cerr << " " << Array[i][j];
		}
		cerr << endl;
	}
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	std::cerr << head << " ";
	print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

// ------------------------------------------------------------------------------------------

signed main() {
	string s;
	cin >> s;
	if (count(all(s), 'A') == 3 or count(all(s), 'B') == 3) {
		puts("No");
	} else {
		puts("Yes");
	}

	return 0;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
a1 = list(li())
a2 = list(li())

ans = 0

for i in range(n):
    tmp = sum(a1[:i+1] + a2[i:])
    if tmp > ans:
        ans = tmp
        
print(ans)

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

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()


def main():
	n=II()
	A=LI()
	A.sort()

	ans=1
	for i in A:
		ans*=i
		if ans>10**18:
			print(-1)
			exit()

	print(ans)








if __name__ == "__main__":
	main()


Measured memory_bytes: 20124
#include<bits/stdc++.h>
using namespace std;
int main() {
  int sum = 0;
  int N; cin >> N;
  vector<int> v(N+1);
  for (int i = 0; i < N; i++) cin >> v[i], sum += v[i];
  reverse(v.begin(), v.end());
  for (int i = 0; i < N; i++) v[i+1] += v[i];
  int now = 0;
  int res = v[N-1];
  for (int i = 1; i <= N; i++) {
    int x; cin >> x;
    sum += x;
    now += x;
    if (i != N) res = min(res, now + v[N-1-i]);
  }
  cout << sum - res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define endl "\n"
#define int long long int 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int N = 505 ;


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

Measured memory_bytes: 256
function Main(input) {

	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
    
    let x1 = parseInt(input[0].split(" ")[0]);
    let x2 = parseInt(input[0].split(" ")[1]);
    let x3 = parseInt(input[0].split(" ")[2]);
    let x4 = parseInt(input[0].split(" ")[3]);
    let x5 = parseInt(input[0].split(" ")[4]);
    
    if (x1 == 0) console.log("1");
    else if (x2 == 0) console.log("2");
    else if (x3 == 0) console.log("3");
    else if (x4 == 0) console.log("4");
    else if (x5 == 0) console.log("5");
    
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29608
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
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> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;

/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/set<int> getDivisor(int n){set<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.insert(i);if(i!=n/i){v.insert(n/i);}}} return v;}
v<int> getDivisorv(int n){v<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}} return v;}


signed _main(){
  int N; cin >> N;
  set<int> s=getDivisor(N-1);
  v<int> s2=getDivisorv(N);
  s.insert(2);
  s.erase(1);
  fore(i,s2){
    if(i==1) continue;
    int n=N;
    while(1){
      if(n%i==0) n/=i;
      else break;
    }
    if(n%i==1){
      //cout << "i " << i << endl;
      s.insert(i);
    }
  }
  cout << s.size() << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>
#include <math.h>
#include <algorithm>
#include <sstream>
#include <list>

using namespace std;

int main()
{
	vector<int>	a;
	a.resize(5);
	cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];

	int min = 0;
	
	int i;

	for (i = 0; i < 5; i++)
	{
		if (a[i] % 10 != 0)
		{
			min = i;
			break;
		}
	}

	for (i = 0; i < 5; i++)
	{
		if (i == min)
			continue;

		if (a[min] % 10 > a[i] % 10 && a[i] %10 != 0)
		{
			min = i;
		}
	}

	int res = 0;

	for (i = 0; i < 5; i++)
	{
		if (i != min)
		{
			res += a[i] / 10 * 10 + (a[i] % 10 != 0 ? 10 : 0);
		}
		else
		{
			res += a[i];
		}
	}

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


Measured memory_bytes: 888
n, m = map(int,input().split())
lst = [-1 for i in range(n + 1)]
lst[0] = 0
def find (x):
    if (lst[x] < 0):
        return(x)
    else:
        z = find(lst[x])
        lst[x] = z
        return (z)
def unit(x, y):
    xp = find(x)
    yp = find(y)
    if (xp == yp):
        pass
    else:
        lst[yp] = xp
for i in range(m):
    a, b = map(int,input().split())
    unit(a, b)

ans = -1
for i in range(n + 1):
    if (lst[i] == -1):
        ans = ans + 1

print(ans)



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

using namespace std;

int main() {
  int n;
  cin >> n;
  
  vector<int> masu(n);
  
  for (int i = 0; i < n; i++) {
    cin >> masu.at(i);
  }
  int count = 0;
  for (int i = 0; i < n; i++) {
    if ((i + 1) % 2 == 1 && masu.at(i) % 2 == 1) {
      count++;
    }
  }
  cout << count << endl;
  
}

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

int main(void)
{
	int a1,a2,a3,max=0;
	scanf("%d%d%d",&a1,&a2,&a3);
	if(abs(a1-a2)>max)
		max=abs(a1-a2);
	if(abs(a1-a3)>max)
		max=abs(a1-a3);
	if(abs(a2-a3)>max)
		max=abs(a2-a3);
	printf("%d",max);
	return 0;
}
	

Measured memory_bytes: 128
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c<=32)c=_buff.get();return c;}
ll qpow(ll x,ll k){return k==0?1:1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}
int n;
int sum[100111];
int main()
{
	for(int i=1;i<=100000;i++)
	{
		sum[i]=sum[i/10]+i%10;
	}
	cin>>n;
	int ans=1e9;
	for(int i=1;i<n;i++)
	{
		ans=min(ans,sum[i]+sum[n-i]);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
#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 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-7;
const int inf=1e8;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
vi r;
int n;
vvi tmp;
int f(){
	vvi te(3,vi(n));
	rep(q,3){
		vp t(n);
		rep(i,n)t[i]=pii(-tmp[i][q],i);
		sort(all(t));
		te[q][t[0].second]+=r[0];
		loop(i,1,n){
			if(t[i].first==t[i-1].first)te[q][t[i].second]=te[q][t[i-1].second];
			else te[q][t[i].second]+=r[i];
		}
	}
	vi T(n);
	rep(i,n)T[i]=te[0][i]+te[1][i]+te[2][i];
	int co=0;
	loop(i,1,n)if(T[0]<T[i])co++;
	if(co<8)return 1;
	else return 0;
}
int main(){
	cin>>n;
	r=vi(n);
	rep(i,n)cin>>r[i];
	vvi in(n,vi(3));
	rep(i,n)rep(j,3)cin>>in[i][j];
	int out=inf;
	rep(i,3)loop(j,1,110){
		tmp=in;
		tmp[0][i]+=j;
		if(f()){
			out=min(out,j);
			break;
		}
	}
	if(out!=inf)cout<<out<<endl;
	else cout<<"Saiko"<<endl;
}

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

int main(){
    string s;
    ll k;
    cin>>s>>k;
    int n = s.size();
    if(s == string(n,s[0])){
        cout << n*k/2 <<endl;
        return 0;
    }
    int a1=0,a2=0;
    for(int i=1;i<n;i++){
        if(s[i]==s[i-1]){
            a1++;
            i++;
        }
    }
    for(int i=1;i<2*n;i++){
        if(s[i%n]==s[(i-1)%n]){
            a2++;
            i++;
        }
    }
    cout << a1 + (a2-a1)*(k-1) << endl;
    return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static int mod = 1000000007;  // 10^9+7


		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			//int n = int.Parse(Console.ReadLine());
			//string s = Console.ReadLine();
			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int t = vs[0];
			int x = vs[1];
			Console.WriteLine((double)t / x);

			Console.Out.Flush();
		}
	}
}


Measured memory_bytes: 13396
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np
# from numpy import cumsum  # accumulate
from bisect import bisect_right, bisect_left

def solve():
    N, M, K = MI()
    A = LI()
    B = LI()
    A = [0] + list(accumulate(A))
    B = [0] + list(accumulate(B))

    def is_ok(arg, a):
        # b <= K - a
        # print(arg, B[arg], a, K, B[arg] <= K - a)
        return B[arg] <= K - a

    def meguru_bisect(ng, ok, a):
        while (abs(ok - ng) > 1):
            mid = (ok + ng) // 2
            if is_ok(mid, a):
                ok = mid
            else:
                ng = mid
            # print(ok, ng)
        return ok

    # print(A)
    # print(B)
    ans = 0
    for i, a in enumerate(A):
        idx = meguru_bisect(M+1, -1, a)
        if 0 <= idx <= M:
            ans = max(ans, i + idx)
    print(ans)

        



if __name__ == '__main__':
    solve()


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

int set_bit_count(int n) {
  int n1 = ((n  & 0b0101010101010101010101010101010) >> 1) +
            (n  & 0b1010101010101010101010101010101);
  int n2 = ((n1 & 0b1001100110011001100110011001100) >> 2) +
            (n1 & 0b0110011001100110011001100110011);
  int n3 = ((n2 & 0b1110000111100001111000011110000) >> 4) +
            (n2 & 0b0001111000011110000111100001111);
  int n4 = ((n3 & 0b1111111000000001111111100000000) >> 8) +
            (n3 & 0b0000000111111110000000011111111);
  int n5 = ((n4 & 0b1111111111111110000000000000000) >> 16) +
            (n4 & 0b0000000000000001111111111111111);
  return n5;
}

int main() {
  int N, M; cin >> N >> M;
  int A[M], B[M], C[M];
  for (int i = 0; i < M; i++) {
    cin >> A[i] >> B[i];
    C[i] = 0;
    for (int j = 0; j < B[i]; j++) {
      int k; cin >> k;
      C[i] |= (1<<(k-1));
    }
  }
  int nodes_i[1<<N]; for (int i = 0; i < 1<<N; i++) nodes_i[i] = i;
  sort(nodes_i, nodes_i + (1<<N), [](int &a, int &b) {
    return set_bit_count(a) < set_bit_count(b);
  });
  int price[1<<N];
  for (int i = 0; i < 1<<N; i++) {
    if (i) price[i] = -1;
    else price[i] = 0;
  }
  for (int i = 0; i < 1<<N; i++) {
    int node_i = nodes_i[i];
    for (int j = 0; j < M; j++) {
      int head_i = node_i | C[j];
      int p = price[node_i];
      int head_p = p + A[j];
      if (p >= 0) {
        if (price[head_i] == -1) price[head_i] = head_p;
        else price[head_i] = min(price[head_i], head_p);
      }
    }
  }
  cout << price[(1<<N)-1] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n, k, x, y;
	scanf("%d", &n);
	scanf("%d", &k);
	scanf("%d", &x);
	scanf("%d", &y);
	printf("%d\n", min(k, n) * x + max(0, n - k) * y);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int partition(int *,int ,int );

int main(){
  int i, j, n, p, A[100000];

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

  p = partition(A, 0, n-1);

  for(i = 0; i < n-1; i++){
    if(i == p){
      printf("[%d] ",A[i]);
    }else{
      printf("%d ",A[i]);
    }
  }
  printf("%d\n", A[n-1]);
  
  return 0;
}

int partition(int *A,int  p,int  r){
  
  int i, j, x, tmp;

  x = A[r];

  i = p-1;

  for (j = p; j <= r-1; j++){
    if (A[j] <= x){
      i = i+1;
      tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    }
  }

  tmp = A[i+1];
  A[i+1] = A[r];
  A[r] = tmp;

  return i+1;
}



Measured memory_bytes: 2120