akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long 
#define ii pair<int,int>
#define iii pair<int,ii>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)/2)
#define all(x) x.begin(),x.end()
#define pw(x) (1<<(x))
#define inf 1000000005
#define MOD 1000000007 
#define N 105
#define M 1000003
#define LOG 20
#define KOK 250
#define EPS 0.0000001
using namespace std;

int n,cnt;
int tut[N],h[N],dp[N][N],vis[N][N];

int mul(int x,int y) {
	
	return (ll)x*y%MOD;

}

int add(int x,int y) {

	x+=y;

	if(x>=MOD) x-=MOD;
	if(x<0) x+=MOD;

	return x;

}

int fe(int x,int y) {

	if(y==0) return 1;
	if(y&1) return mul(x,fe(x,y-1));

	int res=fe(x,y>>1);

	return mul(res,res);

}

int f(int pos,int bef) {

	if(pos>n) return 1;

	if(vis[pos][bef]) return dp[pos][bef];

	vis[pos][bef]=1;

	int& r=dp[pos][bef];

	if(h[pos-1]>=h[pos]) {

		if(bef>h[pos]) {

			r=add(r,mul(2,f(pos+1,cnt+1)));

		}
		else {

			r=add(r,f(pos+1,bef));

		}

	}
	else {

		if(bef>h[pos]) {

			for(int i=h[pos-1]+1;i<=h[pos];i++) {

				r=add(r,mul(f(pos+1,i),mul(add(fe(2,tut[i]-tut[i-1]-(i-1==0)),MOD-1),fe(2,tut[h[pos]]-tut[i]))));

			}

			r=add(r,f(pos+1,cnt+1));

			r=mul(r,2);

		}
		else {

			r=add(r,mul(f(pos+1,bef),fe(2,tut[h[pos]]-tut[h[pos-1]])));

		}

	}

	return r;

}

void compress() {

	map<int,int> has;

	for(int i=1;i<=n;i++) has[h[i]]=1;

	for(auto& x:has) {

		++cnt;

		tut[cnt]=x.st;
		x.nd=cnt;

	}

	for(int i=1;i<=n;i++) h[i]=has[h[i]];

}

int main() {

	scanf("%d",&n);

	for(int i=1;i<=n;i++) {
	
		scanf("%d",h+i);
	
	}

	compress();

	printf("%d",f(1,cnt+1));

}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	ll n;cin >> n;
	
	vector<ll> v;
	ll wari = 0;
	ll check = 0;
	REP(i,n)
	{
		ll tmp;cin >> tmp;
		v.PB(tmp);
		check += tmp;
		wari += i+1;
	}
	
	if(check % wari != 0)
	{
		cout << "NO" << endl;
		return 0;
	}
	
	check /= wari;
	//cout << "!!" << check << endl;
	//cout << check << endl;
	ll ans = 0;
	REP(i,n)
	{
		if(v[i] + check != v[(i+1)%n])
		{
			ll tmp = v[i] - v[(i+1)%n] + check;
			if(tmp % n != 0)
			{
				cout << "NO" << endl;
				return 0;
			}
	//		cout << tmp << endl;
			ans += max(0LL,tmp / n);
		}
	}

	
	//cout << ans << ' ' << check << endl;
	if(ans == check)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
		
	
	
	return 0;
}

Measured memory_bytes: 1400
#include <iostream>

using namespace std;

int a[100];
int n;

void out(){
    int i;
    cout<<a[0];
    for(i=1;i<n;i++){
        cout<<" "<<a[i];
    }
    cout<<endl;
}

int main()
{
    cin>>n;
    int i;
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    out();
    for(i=1;i<n;i++){
        int v=a[i];
        int j=i-1;
        while(a[j]>v&&j>=0){
            a[j+1]=a[j];
            j--;
        }
        a[j+1]=v;
        out();
    }
    return 0;
}

Measured memory_bytes: 3092
import java.util.*;
public class Main {
	
	public static void main (String[] args)
	{
		Scanner sc = new Scanner (System.in);
		int nums = sc.nextInt();
		long[] arr = new long[2];
		long[] sticks = new long[nums];
		for (int i= 0; i < nums; i++)
			sticks[i]=sc.nextInt();
		Arrays.sort(sticks);
		int count = 0;
		//for (int i = nums - 1; i >= 1; i--)
		while(nums -- > 1)
		{
			if (sticks[nums]==sticks[nums-1])
			{
				arr[count]= sticks[nums];
				nums--;
				count++;
			}
			if (count==2)
				break;
		}
			System.out.println(arr[0]*arr[1]);
		
	}
	
	
	
}


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

// Optimization

//#pragma GCC optimize("O3")
#define endl '\n'

// Shortcut

#define int long long
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define fi first
#define se second
#define For(i, l, r) for (int i = l; i < r; i++)
#define ForE(i, l, r) for (int i = l; i <= r; i++)
#define Ford(i, r, l) for (int i = r; i > l; i--)
#define FordE(i, r, l) for (int i = r; i >= l; i--)
#define Fora(i, a) for (auto i : a)

// I/O & Debug

#define PrintV(a) Fora(iiii, a) cout << iiii << ' '; cout << endl;
#define PrintVl(a) Fora(iiii, a) cout << iiii << endl;
#define PrintA(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << ' '; cout << endl;
#define PrintAl(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << endl;
#define Ptest(x) return cout << x, 0;
#define gl(s) getline(cin, s);
#define setpre(x) fixed << setprecision(x)
/*
#define debug(args...){ string _sDEB = #args; replace(_sDEB.begin(), _sDEB.end(), ',', ' '); stringstream _ssDEB(_sDEB); istream_iterator<string> _itDEB(_ssDEB); DEB(_itDEB, args); }
void DEB(istream_iterator<string> it) {}
template<typename T, typename... Args>
void DEB(istream_iterator<string> it, T a, Args... args){
    cout << *it << " = " << a << endl;
    DEB(++it, args...);
}
*/

// Functions

//#define isvowel(a) (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define bend(a) a.begin(), a.end()
#define rbend(a) a.rbegin(), a.rend()
#define mset(a) memset(a, 0, sizeof(a))
#define mset1(a) memset(a, 1, sizeof(a))
#define msetn1(a) memset(a, -1, sizeof(a))
#define msetinf(a) memset(a, 0x3f, sizeof(a))
#define gcd __gcd
#define __builtin_popcount __builtin_popcountll
//mt19937 rando(chrono::steady_clock::now().time_since_epoch().count());

// Data Structure

#define pque priority_queue
#define mts multiset
#define y0 _y0_
#define y1 _y1_
#define div divi
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;

const int N = 2e5 + 5;
int mod = 1e9 + 7, mod1 = 998244353, mod2 = 1e9 + 9, inf = 1e9 + 7;
ll infll = 1e18 + 7;



signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int x, y; cin >> x >> y;
    if (y % 2 == 0 && y >= x * 2 && y <= x * 4) cout << "Yes";
    else cout << "No";
}

/*
==================================+
INPUT:                            |
------------------------------    |

------------------------------    |
==================================+
OUTPUT:                           |
------------------------------    |

------------------------------    |
==================================+
*/


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

int main()
{
	double w, h, x, y;
	int ans = 0;
	cin >> w >> h >> x >> y;
	if (w == h && x == y && 0 < x && x < w && 0 < y && y < h)
		ans = 1;
	if (w / 2.0 == x && h / 2.0 == y && 0 < x && x < w && 0 < y && y < h)
		ans = 1;
	cout << fixed << setprecision(10) << (w * h / 2) << " " << ans << endl;
	return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define FOR_EX(i, a, b) for (int i = a; i < b; i++)
#define FOR_IN(i, a, b) for (int i = a; i <= b; i++)

#define ALL(a) a.begin(), a.end()

// g++ -std=c++17 -O2 -Wall template.cpp -o template
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    // cout << fixed << setprecision(10);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // Solution
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    int steps = 0;
    while (a[0] != a[1] || a[1] != a[2]) {
        sort(a, a + 3);
        // If any 2 are same
        if (a[0] == a[1]) {
            steps += a[2] - a[0];
            a[0] = a[2];
            a[1] = a[2];
        } else if (a[1] == a[2]) {
            steps++;
            a[0] += 2;
        } else {
            a[0]++;
            a[1]++;
            steps++;
        }
    }
    cout << steps << endl;
}


Measured memory_bytes: 256
N=int(input())
mod=1000000007
S=input()
data=[]
exist=set()
for s in S:
    if s in exist:
        data[-1]+=1
    elif s not in exist:
        data.append(1)
        exist|={s,}
if data[0]==1:
    ans=3
elif data[0]==2:
    ans=6
for i in range(1,len(data)):
    if (data[i-1],data[i])==(1,1):ans=(ans*2)%mod
    elif (data[i-1],data[i])==(1,2):ans=(ans*2)%mod
    elif (data[i-1],data[i])==(2,1):ans=ans
    elif (data[i-1],data[i])==(2,2):ans=(ans*3)%mod
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
using namespace std;

int main(){
    int N,K;
    cin>>N>>K;
    double p=0;
    for(int i=1; i<=N; i++){
        int cnt = 0;
        int j = i;
        while(j<K){
            j*=2;;
            cnt++;
        }
        p+=1.0/N/(1<<cnt);
    }
    cout<< setprecision(10)<<p;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long A = sc.nextLong();
        long B = sc.nextLong();
        long a = N/(A+B);
        long b = N%(A+B);
        System.out.println(a * A + (b > A ? A : b));
    }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int q, a = 0;
    string s;
    cin >> s >> q;
    deque<char> deq;
    for(char i : s)deq.push_back(i);
    rep(i, q){
        int t;
        cin >> t;
        if(t == 1){
            a++;
            a %= 2;
        }
        else{
            int f;
            char c;
            cin >> f >> c;
            if(a == 0){
                if(f == 1)deq.push_front(c);
                else deq.push_back(c);
            }
            else{
                if(f == 1)deq.push_back(c);
                else deq.push_front(c);
            }
        }
    }
    if(a == 1)reverse(all(deq));
    for(char i : deq)cout << i;
    cout << endl;
}   


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

typedef long long ll;
typedef long double ld;

#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define max(a,b) (a>b ? a : b)
#define min(a,b) (a<=b ? a : b)


#define pb push_back
#define f first
#define s second
const int N=1e5+5;
using namespace std;
int h[N];
int dp[N];
int solve(int i,int n)
{
    if(i>=n-1)return 0;
    if(dp[i]!=-1)return dp[i];
    int t = abs(h[i]-h[i+1]);
    if(i+2<n)t=min(abs(h[i]-h[i+2])+solve(i+2,n),t+solve(i+1,n));
    return dp[i]=t;

}
int main()
{
    ios::sync_with_stdio(0);
    memset(dp,-1,sizeof(dp));
    int n;
    cin >> n;
    rep(i,0,n)cin >> h[i];
    cout << solve(0,n);

    return 0;
}


Measured memory_bytes: 8232
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <iostream> 
#include <iomanip>  
#include <string>
#include <sstream>  
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <cstring>
#include <cmath>
#include <cassert>


#define INF              (int)1000000007
#define EPS              1e-9
#define pb               push_back
#define mp               make_pair
#define all(c)           c.begin(), c.end()
#define forall(i,a,b)    for(int i=a;i<(b);++i)
#define trav(a,x)        for(auto & a: x)
#define in(a,b)          ((b).find(a) != (b).end())
#define sz(c)            (int)(c).size()
#define input(a)         for(auto & x : a) cin >> x;

using namespace std;

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

#ifdef DEBUG
#define trace(...)       __f(#__VA_ARGS__, __VA_ARGS__)
#define debug(args...)   {dbg,args; clog<<endl;}
#define print_( a )      for( auto & x : a ) clog << x << ' '; clog << '\n';
#define printPair_( a )  for( auto & x : a ) clog << '(' << x.first << ',' << x.second << ')' << ' '; clog << '\n';
#else
#define trace(...)       
#define debug(args...)            
#define print_( a )               
#define printPair_( a )           
#endif

struct debugger {
  template<typename T> debugger& operator , (const T& x) {    
    clog << x << " ";    return *this;    
  }
}dbg;

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " | ";
    __f(comma + 1, args...);
}

auto ____ =[]() { std::ios::sync_with_stdio(0); cin.tie(0); return nullptr; }();

int main( int argc, char * argv[] ){
  int n, m; cin >> n >> m ; 
  vvi mtx(n, vi(m));
  vector<string> B(n);
  forall(i,0,n) cin >> B[i];

  vector<vector<ll>> dp(n, vector<ll>(m, 0));
  dp[0][0] = 1;
  forall(i,0,n){
    forall(j,0,m){
      if( B[i][j] == '#' ) continue;
      if( i > 0 ){
        dp[i][j] += dp[i-1][j];
      }
      if( j > 0 ){
        dp[i][j] += dp[i][j-1];
      }
      dp[i][j] %= INF;
    }
  }
  cout << dp[n-1][m-1] << endl;
  return 0;
}


Measured memory_bytes: 13184
N, K = map(int, input().split())
P = list(map(int, input().split()))
count = 0
new_list = []
while count < K:
    min = P[0]
    for i in P:
        if min > i:
            min = i
    new_list.append(min)
    P.remove(min)
    count += 1
print(sum(new_list))

Measured memory_bytes: 9200
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;

ll n, k;
const ll mod = 1000000007;


int main(){
   int r;
   cin >> r;
   out(3*r*r);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define db(x) (cerr << #x << ": " << (x) << '\n')
#define cps CLOCKS_PER_SEC
#define tests(t) int t; cin >> t; while(t--)
#define iceil(n, x) (((n) + (x) - 1) / (x))
#define eb emplace_back
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define sz size()
#define all(v) (v).begin(), (v).end()
#define uni(v) sort(all(v)), (v).erase(unique(all(v)), (v).end())
#define fi first
#define se second
#define bitcount(x) __builtin_popcount(x)
#define bit(x) (1LL << x)
#define PI acos(-1.0)
#define EPS 1e-9

#define mod 1000000007
#define maxn 200015

using namespace std;

using namespace __gnu_pbds;
template<class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
///All indexing is 0-based
///methods: find_by_order(k); & order_of_key(k);
///To make it an ordered_multiset, use pairs of (value, time_of_insertion)
///to distinguish values which are similar

typedef long long ll;
typedef double ld;
typedef pair<ll, ll> par;


char s[14];

int main()
{
    #ifdef acm
    freopen("a.in","r",stdin);
    #endif // acm
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> s;

    if(s[1] == 'B')
        cout << "ARC\n";
    else
        cout << "ABC\n";






}


Measured memory_bytes: 3652
#include<stdio.h>
#include<string.h>
int main(){
  int i,j,k;
  char S[10];
  int a,b;
  int ans=0,tmp;
  scanf("%s %d %d",S,&a,&b);
  k = atoi(S);
  j = strlen(S);
  int s,n,m;
  for(i = 1;i<=k;i++){
    s = i;
    tmp=0;
    for(n=0;n < j;n++){
      tmp += s %10;
      s /= 10;
    }
  if(tmp >= a && tmp <= b){ 
    ans+=i;
  }
  }
  
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 128
from collections import Counter
from itertools import chain
from sys import stdin
d = Counter(chain.from_iterable([list(map(int, stdin.readline().rstrip().split())) for _ in range(3)]))
if d[1] <= 2 and d[2] <= 2 and d[3] <= 2 and d[4] <= 2:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 9404
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;


int main(int argc, const char * argv[]) {
  int n; cin >> n;
  cout << n*n*n << endl;
  return 0;
}

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

int main()
{
  int N,T;
  while(cin >> N >> T, (N||T)) {
    string s;
    cin >> s;

    double dp[2005][2] = {0};
    dp[0][0] = 1.0;

    for(int i=1; i<=T; i++) {
      for(int j=0; j<N; j++)
        dp[j][i%2] = 0.0;

      for(int j=0; j<N; j++)
        for(int k=1; k<=6; k++)
          dp[(j+k)%N][i%2] += dp[j][(i+1)%2] / 6.0;
    }

    double res = 0;
    for(int i=0; i<N; i++) {
      double sum = 0;
      for(int j=0; j<N; j++)
        if(s[(i+j)%N]=='R') sum += dp[j][T%2];
      res = max(res, sum);
    }

    cout.setf(ios::fixed);
    cout.precision(10);

    cout << res << endl;
  }
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<deque>

using ll = long long;
using namespace std;
const int inf = 1e9 + 10;
const int dy[4] = { 1,0,-1,0 };
const int dx[4] = { 0,1,0,-1 };


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

	int h, w;

	cin >> h >> w;

	int ch, cw; // ウィザードの位置
	int dh, dw; //目的の位置

	cin >>ch >> cw >> dh >> dw;

	ch--,cw--,dh--,dw--;

	vector<string> s(h); // 高さh幅wのステージ
	vector<vector<int>> dist(h, vector<int>(w, inf)); //ワープのコスト
	

	for (int i = 0; i < h; i++) {
		cin >> s[i];
	}

	dist[ch][cw] = 0;
	
	deque<pair<int, int>> q; //発見済みのキューを収納
	q.push_back({ ch,cw });

	while (!(q.empty())) {
		int x = q.front().first, y = q.front().second;
		q.pop_front();
		// 通常移動
		for (int i = 0; i < 4; i++) {
			int nx = x + dx[i], ny = y + dy[i];
			if (nx < 0 || ny < 0 || nx >= h || ny >= w) continue;
			if (s[nx][ny] == '#') continue;
			if (dist[nx][ny] > dist[x][y]) {
				dist[nx][ny] = dist[x][y];
				q.push_front({ nx,ny });
			}
		}
		// ワープ移動
		for (int i = -2; i <= 2; i++) {
			for (int j = -2; j <= 2; j++) {
				int nx = x + i, ny = y + j;
				if (nx < 0 || ny < 0 || nx >= h || ny >= w) continue;
				if (s[nx][ny] == '#') continue;
				if (dist[nx][ny] > dist[x][y] + 1) {
					dist[nx][ny] = dist[x][y] + 1;
					q.push_back({ nx,ny });
				}

			}
		}

	}
	if (dist[dh][dw] == inf) {
		cout << "-1";
	}
	else {
		cout << dist[dh][dw];
	}
	return 0;
}

Measured memory_bytes: 8692
using System;
using System.Text;

class CitySavers
{
    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        string[] inputA = Console.ReadLine().Split(' ');
        string[] inputB = Console.ReadLine().Split(' ');
        long killCount = 0;
        var A = new int[inputA.Length];
        var B = new int[inputB.Length + 1];

        for (var i = 0; i < N + 1; i++)
        {
            A[i] = int.Parse(inputA[i]);
        }

        for(var i = 0; i<N; i++)
        {
            B[i] = int.Parse(inputB[i]);
        }


        for (var i = 0; i < N + 1; i++)
        {
            if (A[i] <= B[i])
            {
                var addAttack = B[i] - A[i];
                var addkillCount = 0;
                if (i != N)
                {
                    var temp = A[i + 1] - addAttack;
                    
                    if (temp < 0)
                    {
                        addkillCount = A[i + 1];
                        A[i + 1] = 0;
                    }
                    else
                    {
                        A[i + 1] = temp;
                        addkillCount += addAttack;
                    }
                }
                killCount += A[i] + addkillCount;
            }
            else if (A[i] > B[i])
            {
                killCount += B[i];
            }
        }
        Console.WriteLine(killCount);
    }
}


Measured memory_bytes: 36444
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T>inline void print(const T& a) { cout << a << "\n"; }

//merge [l,m) with [m,r)
void MergeSort(VI& a, VI& tmp, int l, int r) {
    if (l + 1 == r)return;
    int m = l + r >> 1;
    MergeSort(a, tmp, l, m);
    MergeSort(a, tmp, m, r);
    int i = l, j = m, k = l;
    for (; i < m || j < r; ++k) {
        if (i == m)
            tmp[k] = a[j++];
        else if (j == r)
            tmp[k] = a[i++];
        else if (a[i] < a[j])
            tmp[k] = a[i++];
        else
            tmp[k] = a[j++];
    }
    for (k = l; k < r; ++k)
        a[k] = tmp[k];
}

int main() {
    init();

    int n, k; cin >> n >> k;
    VI h(n); cin >> h;

    VI tmp(n);
    MergeSort(h, tmp, 0, n);

    int64_t ans = 0;
    FOR(i, 0, n - k)ans += h[i];
    print(ans);

    return 0;
}


Measured memory_bytes: 4740
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;


int main(){
  long ii,jj,kk;
  vector<int> ret;
  int a[3];
  long long int min,max;

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

  min = 10e10;
  max = -10e10;

  for(ii=0;ii<3;ii++){
    if(min > a[ii]){
      min = a[ii];
    }
    if(max < a[ii]){
      max = a[ii];
    }
  }

  cout << min << " " << max << endl;
  return 0;
}



Measured memory_bytes: 3120
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Arrays;
import java.util.Collections;
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int d[] = new int[n];
    int sum = 0;
    for (int i = 0;i < n;i++) {
      d[i] = scan.nextInt();
    }
    for (int i = 0;i < n;i++) {
      for (int j = i + 1;j < n;j++) {
        sum += d[i] * d[j];
      }
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 35744
from sys import stdin
from sys import exit
def main():
    #入力
    readline=stdin.readline
    n=int(readline())

    if n%2==1:
        print(0)
        exit()
    
    n//=2
    ans=0
    x=5
    while n//x>=1:
        ans+=n//x
        x*=5

    print(ans)

if __name__=="__main__":
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
struct P
{
    //string r;
    int x;

    int y;
    //string r;
    bool operator<(const P &a)const{
       // if(y!=a.y)
       // return y>a.y;
       return x>a.x;
//        return z>a.z;
    }
};
struct S
{
    int x,y;
};
vector<P> v[300333];
//bitset<4001000> bit;
int a,c,i,b,k=-1987654321,d,n,m,e=1987654321;//dy[15]={0,1,0,-1,-1,1,-1,1},dx[15]={1,0,-1,0,1,1,-1,-1};//
int l[2000010];
int o[222333];
int j[222222];
int dx[10]={0,1,0,-1},dy[10]={1,0,-1,0},dz[10]={0,0,0,0,1,-1};

//long long x,y,z[1111][3][1111],mod=1000000007;
//P u[23][2222][2222];
//int j[31][11111];

stack<S> s;
queue<int> q;
queue<int> q1;

//deque<int> de;
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
map<int,int > p[22][22];
//list<int> l;
string r,r2;
//char r[33][33];



int f(int a)
{
    if(a<2) return a;
    return f(a/2)+a%2;
}

int main()
{
    scanf("%d %d",&a,&b);
    if(b<2)
    {
        puts("Yes");
        return 0;
    }
    for(int t=1;t<=b;t++)
    {
        scanf("%d %d %d",&n,&m,&i);
        v[n].push_back({m,i});
        v[m].push_back({n,-i});
        j[m]=1;

    }
    for(int t=1;t<=a;t++)
        l[t]=-2087654321;


    i=0;
    for(int t=1;t<=a;t++)
        if(!j[t]&&v[t].size())
        {
            q1.push(t);
        }

    //memset(l,-1,sizeof(l));
    if(!q1.size())
    {
        puts("No");
        return 0;
    }
    for(;q1.size();q1.pop())
    {
        i=q1.front();
        if(l[i]>-2087654321)
            goto asd;
    l[i]=0;
    e=0;
    k=0;
    q.push(i);
    for(;q.size();q.pop())
    for(int h=0;h<v[q.front()].size();h++)
    {
        if(l[v[q.front()][h].x]==-2087654321)
        {
            l[v[q.front()][h].x]=l[q.front()]+v[q.front()][h].y;
            /*if(l[v[q.front()][h].x]<0||l[v[q.front()][h].x]>1000000000)
            {
                puts("No");
                return 0;
            }*/
            e=max(e,l[v[q.front()][h].x]);
            k=min(k,l[v[q.front()][h].x]);
            q.push(v[q.front()][h].x);

        }
        else
        {
             if(l[v[q.front()][h].x]!=l[q.front()]+v[q.front()][h].y)
             {
                 puts("No");
                 return 0;
             }
        }

    }
    if(e-k>1000000000)
{
    puts("No");
return 0;
}
asd:;
    }
    puts("Yes");
}


Measured memory_bytes: 17792
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer tor = nil->next;
  while(tor != nil && tor->key != key){
    tor = tor->next;
  }
  return tor;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  NodePointer t = nil->prev;
  if ( t == nil ) return;
  deleteNode(t);
}

void delete(int key){
  NodePointer t = listSearch(key);
  if(t == nil)return;
  deleteNode(t);
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(){
  int key, n, i;
  //  int size = 0;
  char com[20];
  // int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ) {scanf("%d",&key); insert(key);/* np++; size++;*/}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	scanf("%d",&key);
	delete(key); //nd++; 
      }
      //size--;
    }
  }

  printList();
  return 0;
}



Measured memory_bytes: 33104
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
 
  for(int i = 0; i < N; i++){
    string S;
    cin >> S;
    if(S == "Y"){
      cout << "Four" << endl;
      break;
    }
    if(i == N - 1){
      cout << "Three" << endl;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);


int main(){
    IOS;
    ll n;cin>>n;
    ll a[n];
    ll sum=0;
    unordered_map<ll,ll>m;
    f(i,0,n){cin>>a[i];sum+=a[i];m[a[i]]++;}
    ll q;cin>>q;
    while(q--){
        ll u,v;cin>>u>>v;
        sum-=m[u]*u;
        sum+=m[u]*v;
        m[v]+=m[u];
        m[u]=0;
        cout<<sum<<"\n";
    }
    return 0;  
} 





Measured memory_bytes: 7844
#!/usr/bin/env python
InText = input()

FS = InText.find(" ")

SS = InText.find(" ",FS+1)

P = int(InText[0:FS])
Q = int(InText[FS+1:SS])
R = int(InText[SS+1:])

Airports = [P,Q,R]

Airports.sort()

print(Airports[0]+Airports[1])

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
  int n,test[10000][3],A[10000]={0},B[10000]={0},C[10000]={0};
  while(1){
    cin >> n;
    if(n==0){
      break;
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<3;j++){
	cin >> test[i][j];
      }
      if(test[i][0]==100 || test[i][1]==100 || test[i][2]==100){
	A[i]++;
      }
      else if((test[i][0]+test[i][1])/2>=90){
	A[i]++;
      }
      else if((test[i][0]+test[i][1]+test[i][2])/3>=80){
	A[i]++;
      }
      else if((test[i][0]+test[i][1]+test[i][2])/3>=70){
	B[i]++;
      }
      else if((test[i][0]+test[i][1]+test[i][2])/3>=50){
	if(test[i][0]>=80 || test[i][0]>=80){
	  B[i]++;
	}
      }
      else{
	C[i]++;
      }
    }
    for(int i=0;i<n;i++){
      if(A[i]!=0){
	cout << "A" << endl;
      }
      else if(B[i]!=0){
	cout << "B" << endl;
      }
      else/* if(C[i]!=0)*/{
	cout << "C" << endl;
      }
    }
    for(int i=0;i<n;i++){
      A[i]=0;
      B[i]=0;
      C[i]=0;
    }
  }
}

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

int main(){
  int a,b,c,d; cin>>a>>b>>c>>d;
  int d1=c-a,d2=d-b;
  cout<<c-d2<<' '<<d+d1<<' '<<a-d2<<' '<<b+d1<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void) {
  unsigned int n, i;
  unsigned int a[3000000];
  long long int sum = 0;
  scanf("%d", &n);
  for (i=0; i<n; i++) {
    scanf("%d", &a[i]);
  }
  
  for (i=1; i<n; i++) {
    if (a[i] < a[i-1]) {
      sum += (long long int)a[i-1]-a[i];
      a[i] = a[i-1];
    }
  }
  
  printf("%lld", sum);
  return 0;
}

Measured memory_bytes: 2472
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;
typedef long long ll;

int main() {

    ll A;
    ll b[2];
    scanf("%lld %lld.%lld", &A, &b[0], &b[1]);
    ll B = b[0] * 100 + b[1];
    cout << (A * B / 100) << endl;
    
    return 0;
}

Measured memory_bytes: 3800
#include <stdio.h>
#include <math.h>

int main(void)
{
	int a, b, c;
	
	while (scanf("%d %d %d", &a, &b, &c) * a != 0){
		int min_diagonal;
		int n;
		
		min_diagonal = a * a + b * b;
		if (min_diagonal > b * b + c * c){
			min_diagonal = b * b + c * c;
		}
		if (min_diagonal > c * c + a * a){
			min_diagonal = c * c + a * a;
		}
		scanf("%d", &n);
		while (n-- > 0){
			int r;
			
			scanf("%d", &r);
			if (r * r * 4 > min_diagonal){
				puts("OK");
			}
			else {
				puts("NA");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 584
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    from itertools import accumulate

    N = int(input())  # len(A)
    A = list(map(int, input().split()))
    zenbu=sum(A)
    B = [0] + A
    B = list(accumulate(B))
    C = [zenbu]*(N+1)
    import numpy as np
    B=np.array(B)
    C=np.array(C)
    D=C-B
    ans=10**18
    for i in range(1, N):
        ans = min(abs(B[i]-D[i]),ans)
    print(ans)
resolve()

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

void solve(){
	ll n,x,t;
	cin>>n>>x>>t;
	ll tym=t*(n/x);
	n=n-(n/x)*x;
	
	// cout<<tym;
	if(n>0) tym+=t;
	cout<<tym;
	
	
}
int main() {
	int t=1;
	// cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const ll inf = ll(1e18) + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  ll n, k; std::cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) std::cin >> a[i];
  sort(rng(a));
  ll l = -inf, r = inf;
  auto ok = [&](ll &x){
    ll tot = 0;
    rep(i, n) {
      if (a[i] < 0) {
        int l = -1, r = n;
        while(l+1 < r) {
          int c = (l+r) / 2;
          if (a[i] * a[c] < x) r = c; else l = c;
        }
        tot += n-r;
      } else {
        int l = -1, r = n;
        while(l+1 < r) {
          int c = (l+r) / 2;
          if (a[i] * a[c] < x) l = c; else r = c;
        }
        tot += r;
      }
      if (a[i] * a[i] < x) tot--;
    }
    tot /= 2;
    return tot < k;
  };
  while(l+1 < r) {
    ll x = (l+r) / 2;
    if (ok(x)) l = x; else r = x;
  }
  std::cout << l << "\n";
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	int n,k,res=0; cin>>n>>k;
	int arr[n];
	for(int i=0;i<n;i++)cin>>arr[i];
	sort(arr,arr+n);
	for(int i=0;i<n;i++){
        while(i<n-1 && arr[i]==arr[i+1])++i; res++;
	}
	if(res<=k)cout<<0;
	else{ int M=200005,m=arr[n-1]; long c=0;
        int a[M]={0};
        for(int i=0;i<n;i++){
            a[arr[i]]++;
        }
        sort(a,a+m+1);
        for(int i=0;i<=m;i++){
            if(a[i]>0){
            c=c+a[i];
            res--;
            if(res<=k)break;}
        }
        cout<<c;
	}
}


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

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  cout << ((b - a) % 2 == 0 ? "Alice" : "Borys") << endl;
  return 0;
} 

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String info = br.readLine();
		String[] split = info.split(" ");
		int H = Integer.parseInt(split[0]);
		int N = Integer.parseInt(split[1]);
		info = br.readLine();
		String[] A = info.split(" ");
		
		for(int i=0; i<N; i++) {
			
			H = H-Integer.parseInt(A[i]);
		}
		
		if(H<=0) {
			System.out.println("Yes");
		}else
			System.out.println("No");
	}
}


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

#define ONLINE_JUDGE
#define pb(a) push_back(a)
#define all(a) (a.begin(), a.end())

using ll = long long;

const int E5 = 1e5;

//////////// Solution /////////////////////////////////

void solve() {
	int n;
	int p[10];
	cin >> n;
	int s = 0;
	int mx = 0;
	for (int i = 0; i < n; ++i) {
		cin >> p[i];
		s += p[i];
		mx = max(p[i],mx);
	}

	s = s - mx + mx/2;
	cout << s << '\n';
}	

/////////// End Solution ///////////////////////////////////////

//////// Initialization ////////////////////////////////////

int main() {

	#ifndef ONLINE_JUDGE
	FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
	clock_t time_start = clock();
	#endif

	ios::sync_with_stdio(false);
	cin.tie(NULL);

	solve();

	#ifndef ONLINE_JUDGE
	fclose(FIN);
	cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
	#endif

	return 0;
}

//////// End Initialization ///////////////////////////////////////

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

int main() {
  int n;
  cin >> n;
  
  vector<float> v(n);
  for(int i = 0; i < n; ++i){
    cin >> v[i];
  }
  
  sort(v.begin(), v.end());
  
  double sum = 0;
  for(int i = n-1; i > 0; --i){
    sum += v[i] / pow(2, n-i);
  }
  sum += v[0] / pow(2, n-1);
  
  cout << sum << endl;  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,X,Y;cin>>A>>B>>C>>X>>Y;
  int AB=C*2;
  long long H=1000000000;
  for(int L=0;L<=100000;L++){
    if(H>AB*L+A*max(0,X-L)+B*max(0,Y-L)){
      H=AB*L+A*max(0,X-L)+B*max(0,Y-L);
    }
  }
  cout<<H<<endl;
}

Measured memory_bytes: 3664
A,B = list(map(int, input().split()))

def gcd(a, b):
  
  # ユークリッド互除法により最大公約数を求める。
  if a < b:
    a, b = b, a

  if a % b == 0:
    return b
  else:
    return gcd(b, a % b)

def lcm(a,b):
  return (a*b)//gcd(a,b)
  
print(lcm(A,B))
      

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

int main()
{
  int N;
  cin>>N;
  if(N>81)cout<<"No"<<endl;
  else if(N%11==0)cout<<"No"<<endl;
  else if(N%13==0)cout<<"No"<<endl;
  else if(N%17==0)cout<<"No"<<endl;
  else if(N%19==0)cout<<"No"<<endl;
  else if(N%23==0)cout<<"No"<<endl;
  else if(N%29==0)cout<<"No"<<endl;
  else if(N%31==0)cout<<"No"<<endl;
  else if(N%37==0)cout<<"No"<<endl;
  else if(N%41==0)cout<<"No"<<endl;
  else if(N%43==0)cout<<"No"<<endl;
  else if(N%47==0)cout<<"No"<<endl;
  else if(N%53==0)cout<<"No"<<endl;
  else if(N%59==0)cout<<"No"<<endl;
  else if(N%61==0)cout<<"No"<<endl;
  else if(N%67==0)cout<<"No"<<endl;
  else if(N%71==0)cout<<"No"<<endl;
  else if(N%73==0)cout<<"No"<<endl;
  else if(N%79==0)cout<<"No"<<endl;
  else if(N==80)cout<<"No"<<endl;
  else if(N==75)cout<<"No"<<endl;
  else if(N==70)cout<<"No"<<endl;
  else if(N==60)cout<<"No"<<endl;
  else if(N==50)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}


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

#define N 200010
int n, a[N], b[N];

int main() {
    while (scanf("%d", &n) != EOF) {
        for (int i = 1; i <= n; ++i) scanf("%d", a + i);
        for (int i = n; i >= 1; --i) {
            int now = 0;
            for (int j = i + i; j <= n; j += i) {
                now += b[j];
                now %= 2;
            }
            b[i] = now ^ a[i];
        }
      vector <int> vec;
      for (int i = 1; i <= n; ++i) if (b[i]) vec.push_back(i);
      int sze = (int)vec.size();
      printf("%d\n", sze);
      for (int i = 0; i < sze; ++i) printf("%d%c", vec[i], " \n"[i == sze - 1]);
    }
    return 0;
}


Measured memory_bytes: 3064
package main

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

var (
	readString func() string
	readBytes  func() []byte
	stdout     *bufio.Writer
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func abs64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func gcd64(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcd64(b, a%b)
}

// readString() string
// readInt() int
// readInt64() int64
// readFloat64() float64

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

func main() {
	defer stdout.Flush()
	N := readInt()
	M := readInt()
	a := make([]int, M)
	m := make(map[int]bool)
	for i := range a {
		a[i] = readInt()
		m[a[i]] = true
	}

	dp := make([]int, N+1)
	dp[0] = 1
	for i := 1; i <= N; i++ {
		if m[i] {
			continue
		}
		dp[i] = dp[i-1]
		if 2 <= i {
			dp[i] = (dp[i] + dp[i-2]) % 1000000007
		}
	}
	println(dp[N])
}

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


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

int main() {
  
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++)
    cin >> vec.at(i);
  
  bool judge = true;
  
  for (int i = 0; i < N; i++){
    int fig = vec.at(i);
    if (fig % 2 == 0) {
      if ((fig % 3 != 0) && ((fig % 5) != 0)) {
        judge = false;
        break;
      }
      if (!(judge))
        break;
    }
  }

  if (judge)
    cout << "APPROVED" << endl;
  else
    cout << "DENIED" << endl;
}

Measured memory_bytes: 256
from collections import Counter
import math
n = int(input())
res = 0
all = []
for i in range(n):
    s = input()
    sor = sorted(s)
    all.append("".join(sor))
counter = dict(Counter(all))
for i in counter.values():
    if i > 1: 
        res += math.factorial(i)/(2*math.factorial(i-2))
print(int(res))

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

struct DisjointSet {
	vector<int> par;

	DisjointSet(int N) : par(N, -1) {}

	bool isSame(int a, int b) {
		return root(a) == root(b);
	}

	int root(int a) {
		if (par[a] < 0) return a;
		par[a] = root(par[a]);
		return par[a];
	}

	int size(int a) {
		return -par[root(a)];
	}

	void unite(int a, int b) {
		if (!isSame(a, b)) {
			a = root(a);
			b = root(b);
			if (size(a) < size(b)) swap(a, b);
			par[a] += par[b];
			par[b] = a;
		}
	}
};

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> A(M), B(M);
	for (int i = 0; i < M; ++i) {
		cin >> A[i] >> B[i];
		--A[i];
		--B[i];
	}
	vector<long> ans(M);
	ans[M - 1] = (long)N * (N - 1) / 2;
	DisjointSet ds(N);
	for (int i = M - 1; i > 0; --i) {
		ans[i - 1] = ans[i];
		if (!ds.isSame(A[i], B[i])) {
			ans[i - 1] -= (long)ds.size(A[i]) * ds.size(B[i]);
			ds.unite(A[i], B[i]);
		}
	}
	for (long& i : ans) cout << i << endl;
}

Measured memory_bytes: 3328
fun main() {
    val (h1, m1, h2, m2, k) = readLine()!!.trim().split(' ').map(String::toInt)
    val fromMinute = h1 * 60 + m1
    val toMinute = h2 * 60 + m2
    println((toMinute - fromMinute - k))
}

Measured memory_bytes: 36460
import collections
N,K=map(int,input().split())
sunuke=[]
for i in range(K):
    d=int(input())
    okashi=input().split()
    for i in range(d):
        sunuke.append(okashi[i])

have_okashi=collections.Counter(sunuke)
print(N-len(have_okashi))

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

int main()
{
    int a[2];
    scanf("%d%d", &a[0], &a[1]);
    for (int i = 0; i < 2; i++)
    {
        if (a[i] == 4 || a[i] == 6 || a[i] == 9 || a[i] == 11)
        {
            a[i] = 1;
        }
        else if (a[i] != 2)
        {
            a[i] = 0;
        }
    }
    if (a[0] == a[1])
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


vector<int> Z_alg(string S) {
	vector<int> ret(S.size(), 0);
	ret[0] = S.size();
	int i = 1, j = 0;
	while (i < S.size()) {
		while (i + j < S.size() && S[j] == S[i + j])j++;
		ret[i] = j;
		if (j == 0) { i++; continue; }
		int k = 1;
		while (i + k < S.size() && k + ret[k] < j)ret[i + k] = ret[k], k++;
		i += k; j -= k;
	}
	return ret;
}


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

	int N, ans = 0;
	cin >> N;
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		auto p = Z_alg(s.substr(i));
		for (int j = 1; j < p.size(); j++)ans = max(ans, min(p[j],j));
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVETSE(c) reverse((c).begin(),(c).end())
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define ALL(a)  (a).begin(),(a).end()
// int gcd(int a,int b){return b?gcd(b,a%b):a;}
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> T maxt(T x,T y) {
    if (x>y) return x;
    else return y;
}
template<class T> T mint(T x,T y) {
    if (x>y) return y;
    else return x;
}
//sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});
//cout << fixed << setprecision(10) << ans << defaultfloat << endl;
typedef long long ll;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<double> Vd;
typedef vector<string> Vs;

//小数出力
double print_double(double d){printf("%.8f", d);}

long long m = 1e9+7, mod = 1e9+7;
//逆元　a/b の modをとるとき -> a*modinv(b)%mod
long long modinv(long long a, long long m = 1e9+7) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

//約数列挙
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}


int main() {
  int r;
  scanf("%d",&r);
  cout << r*r;
}

Measured memory_bytes: 256