akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

// Mirror Cave
// 2013/05/12
public class Main{
	Scanner sc=new Scanner(System.in);

	int m, n;
	int[][] al, ar;

	void run(){
		for(;;){
			m=sc.nextInt();
			n=sc.nextInt();
			if((m|n)==0){
				break;
			}
			al=new int[n][m];
			ar=new int[n][m];
			for(int j=0; j<n; j++){
				String sl=sc.next();
				for(int i=0; i<m; i++){
					al[j][i]=c2i(sl.charAt(i));
				}
				String sr=sc.next();
				for(int i=0; i<m; i++){
					ar[j][i]=c2i(sr.charAt(i));
				}
			}
			solve();
		}
	}

	int B=50;
	boolean[][][][] visited=new boolean[B][B][B][B];

	void solve(){
		for(int a=0; a<B; a++){
			for(int b=0; b<B; b++){
				for(int c=0; c<B; c++){
					for(int d=0; d<B; d++){
						visited[a][b][c][d]=false;
					}
				}
			}
		}
		int xl0=0, yl0=0, xr0=0, yr0=0;
		for(int j=0; j<n; j++){
			for(int i=0; i<m; i++){
				if(al[j][i]==-1){
					xl0=i;
					yl0=j;
					al[j][i]=0;
				}
				if(ar[j][i]==-1){
					xr0=i;
					yr0=j;
					ar[j][i]=0;
				}
			}
		}
		LinkedList<Integer> que=new LinkedList<Integer>();
		que.offer(hash(xl0, yl0, xr0, yr0));
		int[] dxl={0, 0, -1, 1};
		int[] dyl={-1, 1, 0, 0};
		int[] dxr={0, 0, 1, -1};
		int[] dyr={-1, 1, 0, 0};

		boolean yes=false;

		for(; !que.isEmpty()&&!yes;){
			int p=que.poll();
			int xl=p/B/B/B%B, yl=p/B/B%B, xr=p/B%B, yr=p%B;
			for(int i=0; i<4; i++){
				int xl2=xl+dxl[i], yl2=yl+dyl[i], xr2=xr+dxr[i], yr2=yr+dyr[i];
				if(!in(xl2, yl2)||al[yl2][xl2]==1){
					xl2=xl;
					yl2=yl;
				}
				if(!in(xr2, yr2)||ar[yr2][xr2]==1){
					xr2=xr;
					yr2=yr;
				}
				boolean ll=al[yl2][xl2]==2;
				boolean rr=ar[yr2][xr2]==2;
				if(ll^rr){
					continue;
				}
				if(ll&&rr){
					yes=true;
				}
				if(!visited[xl2][yl2][xr2][yr2]){
					visited[xl2][yl2][xr2][yr2]=true;
					que.offer(hash(xl2, yl2, xr2, yr2));
				}
			}
		}
		println(yes?"Yes":"No");
	}

	int hash(int xl, int yl, int xr, int yr){
		return (xl*50+yl)*2500+(xr*50+yr);
	}

	boolean in(int x, int y){
		return x>=0&&x<m&&y>=0&&y<n;
	}

	int c2i(char c){
		switch(c){
		case '.':
			return 0;
		case '#':
			return 1;
		case '%':
			return 2;
		case 'L':
			return -1;
		case 'R':
			return -1;
		default:
			return 0;
		}
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 169240
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {
    Scanner sc = new Scanner(System.in);

    void run() {
        for (;;) {
            // 1 行目 ビルの階数 n(整数)
            // 2 行目 1 つ目のビル a の 1 階から n 階までの壁の情報 a1 a2 ... an(すべて整数;半角空白区切り)
            // 各 ai は、i 階目の壁の情報を表し、意味は以下のとおりです。
            // 0:普通の壁
            // 1:はしご(i 階と i+1 階にまたがる)
            // 2:すべる壁
            // 3 行目 2 つ目のビル b の 1 階から n 階までの壁の情報 b1 b2 ... bn(すべて整数;半角空白区切り)
            int n = sc.nextInt();
            if (n == 0)
                break;
            int fs[][] = new int[2][n];
            for (int i = 0; i < n; i++) {
                fs[0][i] = sc.nextInt();
            }
            for (int i = 0; i < n; i++) {
                fs[1][i] = sc.nextInt();
            }
            Queue<Data> q = new LinkedList<Data>();
            int sfa = 0;
            int sfb = 0;
            if (fs[0][0] == 1)
                while (sfa + 1 < n && fs[0][sfa + 1] == 1)
                    sfa++;
            if (fs[1][0] == 1)
                while (sfb + 1 < n && fs[1][sfb + 1] == 1)
                    sfb++;
            q.add(new Data(0, sfa, 0));
            q.add(new Data(1, sfb, 0));
            Set<String> set = new HashSet<String>();
            boolean na = true;
            while (!q.isEmpty()) {
                Data d = q.poll();
                int b = d.b;
                int f = d.f;
                if (set.contains(b + " " + f))
                    continue;
                set.add(b + " " + f);
                int t = d.t;
                if (f == n - 1 && fs[b][n - 1] != 2) {
                    System.out.println(t);
                    na = false;
                    break;
                }
                int nb = b ^ 1;
                for (int i = 0; i < 3; i++) {
                    // 向かい側のビルへジャンプするときには、
                    // 同じ階・1つ上の階・2 つ上の階の、いずれかに飛び移ることができます。
                    if (i + f >= n)
                        continue;
                    int nf = f + i;
                    switch (fs[nb][i + f]) {
                    case 0:
                        q.add(new Data(nb, nf, t + 1));
                        break;
                    case 1:
                        while (nf + 1 < n && fs[nb][nf + 1] == 1)
                            nf++;
                        q.add(new Data(nb, nf, t + 1));
                        break;
                    case 2:
                        while (fs[nb][nf] == 2)
                            nf--;
                        q.add(new Data(nb, nf, t + 1));
                        break;
                    }
                }

            }
            if (na)
                System.out.println("NA");
        }
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

class Data {
    int b;
    int f;
    int t;

    Data(int b, int f, int t) {
        this.b = b;
        this.f = f;
        this.t = t;
    }

    public String toString() {
        return b + " " + f + " " + t;
    }
}

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

int main() {
	int N , M ,y = 0;
  
  	cin >> N;
  
  	vector<string> vecs(N);
  	for (int i = 0 ; i < N ; i++) cin >> vecs.at(i);
  
  	cin >> M ; 
  
  	vector<string> vect(M);
  	for (int i = 0 ; i < M ; i++) cin >> vect.at(i);
  
  //以上でN,M,s,tの入力を受け取る
  
  
  	for(int i = 0 ; i < N ; i++) {
      int x = 0;
      
      for(int j = 0 ; j< N ; j++) {
        if(vecs.at(i) == vecs.at(j) ) x++;
      }//vecsを検索して加点
      
      
      for(int j = 0 ; j < M ; j++) {
        if(vecs.at(i) == vect.at(j) ) x--;
      }//vectを検索して減点
      
      //この時点でのxを各iで比較したい
      if(y < x) y = x;
    }
  
  	cout << y << endl;
}

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

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String [] n = br.readLine().split(" ");
        
        Dice dice = new Dice(n[0], n[1], n[2], n[3], n[4], n[5]);
        
        int num = Integer.parseInt(br.readLine());
        
        for(int i = 0; i < num; i++) {
            String [] line = br.readLine().split(" ");
            System.out.println(dice.askRight(line[0], line[1]));
        }
    }
}

class Dice {
    private String top;
    private String front;
    private String right;
    private String left;
    private String back;
    private String bottom;
    
    public Dice(String top, String front, String right, String left, String back, String bottom) {
        this.top = top;
        this.front = front;
        this.right = right;
        this.left = left;
        this.back = back;
        this.bottom = bottom;
    }
    
    public String askRight(String top, String front) {
        setTop(top);
        setFront(front);
        return this.right;
    }
    
    private void setTop(String top) {
        for(int i = 0; i < 4; i++) {
            if(this.top.equals(top)) {
                return;
            }
            goNorth();
        }
        
        goEast();

        for(int i = 0; i < 4; i++) {
            if(this.top.equals(top)) {
                return;
            }
            goNorth();
        }
    }
    
    private void setFront(String front) {
        for(int i = 0; i < 4; i++) {
            if(this.front.equals(front)) {
                return;
            }
            leftRotation();
        }
    }
    
    private void leftRotation() {
        String tmp = this.front;
        this.front = this.right;
        this.right = this.back;
        this.back = this.left;
        this.left = tmp;
    }

    public String nowTopNum() {
        return this.top;
    }
    
    public void goSouth() {
        String tmp = this.front;
        this.front = this.top;
        this.top = this.back;
        this.back = this.bottom;
        this.bottom = tmp;
    }

    public void goNorth() {
        String tmp = this.front;
        this.front = this.bottom;
        this.bottom = this.back;
        this.back = this.top;
        this.top = tmp;
    }

    public void goEast() {
        String tmp = this.top;
        this.top = this.left;
        this.left = this.bottom;
        this.bottom = this.right;
        this.right = tmp;
    }

    public void goWest() {
        String tmp = this.top;
        this.top = this.right;
        this.right = this.bottom;
        this.bottom = this.left;
        this.left = tmp;
    }
}



Measured memory_bytes: 24264
/*
 *  Language:   C++
 *  Author:     Debajyoti Dasgupta
 */

#include <bits/stdc++.h>

using namespace std;
#define int long long

signed main() {
    string s, t;
    cin >> s >> t;
    t.pop_back();
    if (s == t)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int a[] = new int[N];
		for(int i=0; i<N; i++){
			a[i] = sc.nextInt();
		}
		sc.close();
		
		long sum=0;
		for(int n:a){
			sum += n;
		}
		long ans = Long.MAX_VALUE;
		long current = 0;
		for(int i=0; i<N-1; i++){
			current += a[i];
			ans = Math.min(ans, Math.abs(sum-2*current));
		}
		
		System.out.println(ans);
	
	}

}

Measured memory_bytes: 64324
"use strict"
function main(arg) {
    //最大は1000000
    var kazua = parseInt(arg.trim().split(" ")[0]);
    var kazub = parseInt(arg.trim().split(" ")[1]);

    
    var plus = kazua + kazub;
    var minus = kazua - kazub;
    var kakeru = kazua * kazub;

    var kotae = 0;

    if(plus >= minus){
        kotae = plus;
    }else{
        kotae = minus;
    }

    if(kotae >= kakeru){
        
    }else{
        kotae = kakeru;
    }
    console.log(kotae);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 11468
while True:
    m,f,r = map(int,input().split())
    t = m + f
    if m == -1 and f == -1 and r == -1:
        break
    if m == -1 or f == -1:
        print('F')
    elif t >= 80:
        print('A')
    elif t >= 65 and t < 80:
        print('B')
    elif t >= 50 and t < 65:
        print('C')
    elif t >= 30 and t < 50:
        if r >= 50:
            print('C')
        else:
            print('D')
    else:
        print('F')


Measured memory_bytes: 5596
#include <iostream>
#include <math.h>

using namespace std;

int main() {
    int N;
    long res = 1;
    cin >> N;
    for (int i = 1; i <= N; i++) {
        for (int j = 2; j <= 7; ++j) {
            if (pow(i, j) <= N && res <= pow(i, j)) {
                res = pow(i, j);
            }
        }
    }
    cout << res << endl;
    return 0;
}

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a[4];
  for (int i = 0; i < 4; i++) cin >> a[i];
  sort(a,a+4);
  if (a[0] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9) puts("YES");
  else puts("NO");
  return 0;
}


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

#define bit(n,k) ((n>>k)&1) //*n no k bit me 1 or 0*/


int main(){
  int n,k;
  cin >> n >> k;
  vector<ll> a(n,0);
  vector<ll> sum(n+1,0);
  rep(i,n){
    cin >> a[i];
    sum[i+1] = sum[i]+a[i];
  }
  vector<ll> b;
  for(int i=1; i<n+1; i++)for(int j=0; j<i; j++){
    b.emplace_back(sum[i]-sum[j]);
  }
  sort(b.rbegin(),b.rend());
  int m = b.size();
  int keta = 40;
  ll ans = 0;
  vector<int> flag(m+10,1);
  while(keta>=0){
    int cnt = 0;
    rep(i,m){
      if(bit(b[i],keta))if(flag[i]==1){
        cnt++;
        flag[i] = 2;
      }
    }
    if(cnt>=k){
      ans |= (1LL<<keta);
      rep(i,m){
        if(flag[i]==1){ flag[i] = 0; } else if(flag[i]==2){ flag[i] = 1; } 
      }
    } else {
      rep(i,m)if(flag[i]==2){ flag[i] = 1; }
    }
    keta--;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6388
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include<math.h>
int main(){
    int n;
    scanf("%d", &n);
    int cont=0, yes=0;
    for(int i =0;i< n;++i){ 
        int a=0, b=0;
        scanf("%d %d", &a, &b);
        if(a==b)
            cont++;
        else
            cont=0 ; 
        if(cont>=3){
            yes=1;
        }
    }
    if(yes == 1)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  bool odd=false;
  long sum=0;
  for(int i=0;i<N;i++){
    int a;
    cin >> a;
    if(odd && a!=0){
      sum++;
      a--;
    }
    sum+=a/2;
    if(a%2==1)odd=true;
    else odd=false;
  }
  cout << sum;
}




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

using namespace std;

int main()
{
   int x, ans;
   cin>>x;
   for(int i=x; ; i++)
   {
     if(i%2==0 && i%x==0)
     {
         ans=i;
         break;
     }
   }
   cout<<ans<<endl;
   return 0;
}


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

int main() {
	
	int n;
	cin>>n;
	
	int arr[n];
	
	for(int i=0;i<n;i++)
	cin>>arr[i];
	
	
	int ans = arr[0];
	
	int count=1;
	
	for(int i=1;i<n;i++){
	    if(arr[i]<=ans)
	    count++;
	    ans = min(ans,arr[i]);
	}
	
	std::cout << count << std::endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

double dist(int x1, int y1, int x2, int y2) {
    return sqrt((double)pow(abs(x2-x1), 2)+(double)pow(abs(y2-y1), 2));
}

int main() {
    int n;
    cin >> n;
    vint x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];

    double ans = 0;
    vint p(n);
    rep(i, n) p[i] = i;

    int count = 0;
    do {
        double d = 0;
        rep(i, n-1) {
            d += dist(x[p[i]], y[p[i]], x[p[i+1]], y[p[i+1]]);
        }
        ans += d;
        count++;
    } while( next_permutation(all(p)) );

    printf("%.10f", ans/(double)count);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <cstring>
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
int dist[123456];
int main(){
    ll k;
    cin >> k;
    deque<ll>d;
    memset(dist,-1,sizeof(dist));
    d.push_back(1);
    dist[1] = 1;
    while(!d.empty()){
        ll x = d.front();
        d.pop_front();
        if(dist[(x+1)%k] == -1 || dist[(x+1)%k] > dist[x]){
            dist[(x+1)%k] = dist[x] + 1;
            d.push_back((x+1)%k);
        }
        if(dist[(x*10)%k] == -1 || dist[(x*10)%k] > dist[x]){
            dist[(x*10)%k] = dist[x];
            d.push_front((x*10)%k);
        }
    }
    cout << dist[0] << endl;
    return 0;
}

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

inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}
//const int INF = 0x3f3f3f3f;
//const int mod=1e9+7;
//const double pi=3.14159265359;
//###################################################################
int main() {
    int n=D();
    if(n%2==0||n%5==0)cout<<-1;
    else{
        int len=1;
        ll x=7;
        while(x%n){
            x*=10;
            x+=7;
            x%=n;
            len++;
        }
        cout<<len;
    }

}

Measured memory_bytes: 3724
// JavaProgram.cpp
// Author : Priydarshi Singh (@dryairship)
// One cat just leads to another. One bug leads to two others.

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

// I like my types defined.
typedef long long           ll;
typedef pair<int, int>      pii;
typedef pair<ll, ll>        pll;
typedef vector<int>         vi;
typedef vector<ll>          vl;
typedef vector<pii>         vii;
typedef vector<pll>         vll;
typedef set<int>            si;
typedef map<string, int>    msi;
typedef map<int, int>       mii;

// Traditional science is all about finding "hashtag define"s.
#define fr(i, n)            for(int i=0; i<(n); ++i)
#define frC(i, n, c)        for(int i=0; (i<(n)) && (c); ++i)
#define frA(i, a, n)        for(int i=a; i<=(n); ++i)
#define frD(i, a, n)        for(int i=a; i>=(n); --i)
#define fill(a)             memset(a, 0, sizeof(a))
#define fill1(a)            memset(a, -1, sizeof(a))
#define revsort(a, b)       sort(a, b, greater<int>())
#define ff                  first
#define ss                  second
#define pb                  push_back 
#define dout                if(DEBUGGING) cout
#define dbg                 if(DEBUGGING) 
#define endl                "\n"

// When you realize MOD > INF...
int DEBUGGING    =          0;
const int INF    =          1000000000;
const int MOD    =          1000000007;
const ll LINF    =          1e18;
const double PI  =          3.1415926535897932;
const double EPS =          1e-7;

// I'D SPAM. Hehe.
ll gcdEx                    (ll a, ll b, ll *x, ll *y){if(!a){*x=0;*y=1;return b;} 
ll x1,y1,gcd=gcdEx          (b%a,a,&x1,&y1); *x=y1-(b/a)*x1;*y=x1; return gcd;}
ll modI(ll b, ll m)         {ll x,y;gcdEx(b,m,&x,&y);return (x%m+m)%m;}
ll modD(ll a, ll b)         {return (modI(b,MOD)*(a%MOD))%MOD;}
ll modS(ll a, ll b)         {return ((a%MOD)-(b%MOD)+MOD)%MOD;}
ll modP(ll x, ll y)         {ll r=1; x%=MOD; while(y>0){if(y&1){r=(r*x)%MOD;} y=y>>1; x=(x*x)%MOD;} return r;}
ll modA(ll a, ll b)         {return ((a%MOD)+(b%MOD))%MOD;}
ll modM(ll a, ll b)         {return ((a%MOD)*(b%MOD))%MOD;}

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

ll wt[105], v[105];
ll dp[100005];

void solve(int TEST_CASE){
    int n, w, tw;
    cin >> n >> w;
    fr(i,n) cin >> wt[i] >> v[i];
    fill(dp);
    fr(i,n){
        frD(j,w-wt[i],0) dp[j+wt[i]] = max(dp[j+wt[i]], dp[j]+v[i]);
    }
    cout << dp[w];
}

int main(int argc, char* argv[]){
    if(argc==2 && argv[1][1]=='v') DEBUGGING = 1;
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin.exceptions(cin.failbit);
    int nTestCases=1;
    //cin >> nTestCases;
    frA(i,1,nTestCases) solve(i);
    return 0;
}

Measured memory_bytes: 4356
n,y = gets.split.map(&:to_i)

if y % 1000 != 0
    puts "-1 -1 -1"
    exit
end

s = y / 10000
s.downto(0) do |i|
    t = (y - i * 10000) / 5000
    t.downto(0) do |j|
        k = (y - i * 10000 - j * 5000) / 1000
        if i + j + k == n
            puts "#{i} #{j} #{k}"
            exit
        end
    end
end
puts "-1 -1 -1"

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

using namespace std;
// using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;

#define un(x)           x.erase(unique(all(x)), x.end())
#define xx              first
#define yy              second
#define pb              push_back
#define all(v)          v.begin(),v.end()

#define D(x)            cerr << #x " = " << x << '\n'
#define DBG             cerr << "Hi!" << '\n'

#define CLR(a)          memset(a,0,sizeof(a))
#define SET(a)          memset(a,-1,sizeof(a))

// inline int setBit(int n,int pos) { return n = n | (1 << pos); }
// inline int resetBit(int n,int pos) { return n = n & ~(1 << pos); }
// inline bool checkBit(int n,int pos) { return (bool)(n & (1 << pos)); }

// int fx[] = {+0, +0, +1, -1, -1, +1, -1, +1};
// int fy[] = {-1, +1, +0, +0, +1, +1, -1, -1};

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// unsigned int num = rng();
// shuffle(V.begin(), V.end(), rng);

/******************************************************************************************/

//const int MAX = 500010;
//const int INF = 0x3f3f3f3f;
//const int MOD = 1000000007;


//inline int add(int a, int b) { return a + b >= MOD ? a + b - MOD : a + b; }
//inline int sub(int a, int b) { return a - b < 0 ? a - b + MOD : a - b; }
//inline int mul(int a, int b) { return (a * 1LL * b) % MOD; }


vector <int> p, q, s;

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
	
	int x, y, a, b, c, v;
	cin >> x >> y >> a >> b >> c;
	
	for(int i=1;i<=a;i++) {
		cin >> v;
		p.push_back(v);
	}
	for(int i=1;i<=b;i++) {
		cin >> v;
		q.push_back(v);
	}
	for(int i=1;i<=c;i++) {
		cin >> v;
		s.push_back(v);
	}

	sort(all(p));
	sort(all(q));

	reverse(all(p));
	reverse(all(q));

	while(p.size() > x) p.pop_back();
	while(q.size() > y) q.pop_back();


	for(int e : p) s.push_back(e);
	for(int e : q) s.push_back(e);

	sort(all(s));
	reverse(all(s));

	ll ans = 0;
	for(int i=0;i<x + y;i++) {
		ans += s[i];
	}
	cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3188
import heapq

N, M = map(int, input().split())
AB = []
for i in range(N):
    a, b = map(int, input().split())
    heapq.heappush(AB, (a, b))

# print(N, M, AB)

ans = 0
work = []
for i in range(M):
    remain = i + 1
    # print('remain={}, AB={}, ans={}'.format(remain, AB, ans))
    while len(AB) > 0:
        ab = heapq.heappop(AB)
        if ab[0] > remain:
            heapq.heappush(AB, ab)
            break
        heapq.heappush(work, (-ab[1], ab[0]))
    if len(work) == 0:
        continue
    v = heapq.heappop(work)
    ans -= v[0]
    # print('work={}'.format(work))
print(ans)


Measured memory_bytes: 114520
#include <bits/stdc++.h>
using namespace std;
bool mymp(int qwe,int rty)
{
	return qwe>rty;
}
int main()
{
	char a[101],b[101];
	int qaq[101],qwq[101],i;
	gets(a);
	gets(b);
	sort(a,a+strlen(a));
	sort(b,b+strlen(b),mymp); 
	if(strcmp(a,b)>=0)
	{
		cout<<"No\n";
	 } 
	else
	{
		cout<<"Yes\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <fstream>

#define LOCAL  1
#define UPLOAD 2

using namespace std;

int calcDist(int x, int y, int x2, int y2){
    return abs(x2-x) + abs(y2-y);
}

int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int a, b;
    cin >> a >> b;
    
    int ret = 0;

    for(int i=0;i<2;i++){
        if(a > b){
            ret += a;
            a--;
        }
        else{
            ret += b;
            b--;
        }
    }

    cout << ret << endl;

    return 0;
}

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

using namespace std;


#define ss second
#define ff first
#define int long long
//#define double long double
#define pb push_back

const int N = 1e6 + 1, MOD = 1e9 + 7, mod = 998244353, INF = 3e18;

mt19937 Flash_new_51(51515);

using vi = vector <int>;
using vp = vector <pair <int, int>>;


bool used[N];

signed main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);
   int n, ans = 1e9;
   cin >> n;
   for (int i = 1; i < n; i++) {
      int k = n - i, i1 = i, sum = 0;
      while (i1 > 0) {
         sum+= (i1 % 10);
         i1/= 10; 
      }
      while (k > 0) {
         sum+= k % 10;
         k/= 10;
      }
      ans = min(ans, sum);
   }
   cout << ans;

}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            long[] A = new long[N + 1];
            long[] B = new long[N];
            string[] input_str = Console.ReadLine().Split(' ');
            string[] input_str2 = Console.ReadLine().Split(' ');
            for (int i = 0; i < N; i++)
            {
                A[i] = long.Parse(input_str[i]);
                B[i] = long.Parse(input_str2[i]);
            }
            A[N] = long.Parse(input_str[N]);
            long Count = 0;
            for (int i = N; i > 0; i--)
            {
                long temp = Math.Min(A[i], B[i - 1]);
                A[i] -= temp;
                B[i - 1] -= temp;
                Count += temp;
                if (B[i-1] > 0)
                {
                    temp = Math.Min(A[i - 1], B[i - 1]);
                    A[i - 1] -= temp;
                    B[i - 1] -= temp;
                    Count += temp;
                }
            }
            Console.WriteLine(Count.ToString());
//            Console.Read();
        }
    }
}

Measured memory_bytes: 36316
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()

	cnt := 0
	for i := 1; i <= n; i++ {
		if keta(i)%2 == 1 {
			cnt++
		}
	}

	fmt.Println(cnt)

}

// 正数の桁数を返す
func keta(n int) int {
	keta := 0
	if n == 0 {
		return 1
	}
	for n > 0 {
		keta++
		n /= 10
	}
	return keta
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1780
#include <bits/stdc++.h>
using namespace std;
#define F(i, a, b) for (int i = (a), _b = (b); i <= _b; i++)
#define Fore(x) for (vector<int>::iterator i = g[x].begin(); i != g[x].end(); i++) if (*i != par)
#define FAIL puts("No"), exit(0)
int rd() {
	int f = 1; char c; do{ c = getchar(); if (c == '-') f = -1; }while (!isdigit(c));
	int x = 0; do{ x = x*10+c-'0', c = getchar(); }while (isdigit(c)); return x*f;
}

const int N = 100005;

int n;
vector<int> g[N];
struct I {
	int l, r, o;
	I(int _l = 0, int _r = 0, int _o = -1): l(_l), r(_r), o(_o) {}
	I tr() { return I(l-1, r+1, o^1); }
	void comb(I a) {
		if (a.l == -1 && a.r == 1) return;
		if (o == -1) return l = a.l, r = a.r, o = a.o, void();
		if (a.o != o) FAIL;
		l = max(l, a.l), r = min(r, a.r);
		if (l > r) FAIL;
	}
	int In(int x) { return l <= x && x <= r; }
}it[N];
int w[N];

void S(int x, int par) {
	Fore(x) {
		S(*i, x);
		it[x].comb(it[*i].tr());
	}
}
void O(int x, int par) {
	Fore(x) {
		it[*i].comb(it[x].tr());
		O(*i, x);
	}
}

void Dw(int x, int par) {
	Fore(x) {
		w[*i] = (it[*i].In(w[x]+1) ? w[x]+1 : w[x]-1);
		Dw(*i, x);
	}
}

int main() {	
	n = rd();
	F(i, 1, n-1) {
		int x = rd(), y = rd();
		g[x].push_back(y), g[y].push_back(x);
	}
	
	F(i, 1, rd()) {
		int v = rd(), p = rd();
		it[v].comb(I(p, p, p&1));
	}
	
	S(1, -1);
	O(1, -1);
	
	w[1] = it[1].l;
	Dw(1, -1);
	puts("Yes");
	F(i, 1, n) printf("%d\n", w[i]);
	
	return 0;
}

Measured memory_bytes: 12672
class LazySegmentTree():
    def __init__(self,n,init,merge_func,ide_ele):
        self.n=(n-1).bit_length()
        self.merge_func=merge_func
        self.ide_ele=ide_ele
        self.data=[0 for i in range(1<<(self.n+1))]
        self.lazy=[0 for i in range(1<<(self.n+1))]
        for i in range(n):
            self.data[2**self.n+i]=init[i]
        for i in range(2**self.n-1,0,-1):
            self.data[i]=self.merge_func(self.data[2*i],self.data[2*i+1])

    def propagate_above(self,i):
        ids=[]
        while i:
            i>>=1
            ids.append(i)
        for v in ids[::-1]:
            self.data[v]+=self.lazy[v]
            self.lazy[2*v]+=self.lazy[v]
            self.lazy[2*v+1]+=self.lazy[v]
            self.lazy[v]=0

    def remerge_above(self,i):
        ids=[]
        while i:
            i>>=1
            self.data[i]=self.merge_func(self.data[2*i]+self.lazy[2*i],self.data[2*i+1]+self.lazy[2*i+1])

    def update(self,l,r,x):
        l+=1<<self.n
        r+=1<<self.n
        l0=l//(l&-l)
        r0=r//(r&-r)-1
        self.propagate_above(l0)
        self.propagate_above(r0)
        while l<r:
            if l&1:
                self.lazy[l]+=x
                l+=1
            if r&1:
                self.lazy[r-1]+=x
            l>>=1
            r>>=1
        self.remerge_above(l0)
        self.remerge_above(r0)

    def query(self,l,r):
        l+=1<<self.n
        r+=1<<self.n
        l0=l//(l&-l)
        r0=r//(r&-r)-1
        self.propagate_above(l0)
        self.propagate_above(r0)
        res=self.ide_ele
        while l<r:
            if l&1:
                res=self.merge_func(res,self.data[l]+self.lazy[l])
                l+=1
            if r&1:
                res=self.merge_func(res,self.data[r-1]+self.lazy[r-1])
            l>>=1
            r>>=1
        return res

import sys

input=sys.stdin.readline

N,M=map(int,input().split())
interval=[[] for i in range(N)]
for i in range(M):
    l,r,a=map(int,input().split())
    interval[l-1].append((r-1,a))

init=[0]*N
LST=LazySegmentTree(N,init,merge_func=min,ide_ele=10**18)

Max=[0]*N
for i in range(N-1,-1,-1):
    for r,a in interval[i]:
        LST.update(i,r+1,-a)
    Max[i]=max(-LST.query(0,N),0)
    if i:
        LST.update(i-1,i,-Max[i])

print(Max[0])

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

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

int main() {
    string s;
	cin >> s;
    for(int i=0;i<s.length()/2;++i){
        if(s[i]!=s[s.length()-i-1]){
            cout<<"No";
            return 0;
        }
    }
    if(s.length()==3){
        cout<<"Yes";
        return 0;
    }
    int n=s.length();
    string t(s.c_str(),s.c_str()+(n-1)/2);
    for(int i=0;i<t.length()/2;++i){
        if(t[i]!=t[t.length()-i-1]){
            cout<<"No";
            return 0;
        }
    }
    string u(s.c_str()+(n+3)/2,s.c_str()-1+s.length());
    for(int i=0;i<u.length()/2;++i){
        if(u[i]!=u[u.length()-i-1]){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn gcd(a: usize, b: usize) -> usize {
    if b > a {
        return gcd(b, a);
    }
    if a % b == 0 {
        return b;
    }
    gcd(b, a % b)
}

fn main() {
    input! {
        a: usize,
        b: usize,
    }
    println!("{}", a * b / gcd(a, b));
}


Measured memory_bytes: 4352
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;


class Solve
{
  public Solve() { }
  public static int Main()
  {
    new Solve().calc();
    return 0;
  }


  Scanner cin;

  void calc()
  {
    cin = new Scanner();
    long a = cin.nextLong();
    long b = cin.nextLong();
    long c = cin.nextLong();

    long l = c - a - b;
    if (l < 0)
    {
      Console.WriteLine("No");
      return;
    }
    long r = 4 * a * b;

    Console.WriteLine(l * l > r ? "Yes" : "No");
  }
}
class Modulo
{
  private const int M = 1000000007;
  private readonly int[] m_facs;
  public int Mul(int a, int b)
  {
    return (int)(Math.BigMul(a, b) % M);
  }
  public Modulo(int n)
  {
    m_facs = new int[n + 1];
    m_facs[0] = 1;
    for (int i = 1; i <= n; ++i)
    {
      m_facs[i] = Mul(m_facs[i - 1], i);
    }
  }
  public int Fac(int n)
  {
    return m_facs[n];
  }
  public int Pow(int a, int m)
  {
    switch (m)
    {
      case 0:
        return 1;
      case 1:
        return a;
      default:
        int p1 = Pow(a, m / 2);
        int p2 = Mul(p1, p1);
        return ((m % 2) == 0) ? p2 : Mul(p2, a);
    }
  }
  public int Div(int a, int b)
  {
    return Mul(a, Pow(b, M - 2));
  }
  public int Ncr(int n, int r)
  {
    if (n < r) { return 0; }
    if (n == r) { return 1; }
    int res = Fac(n);
    res = Div(res, Fac(r));
    res = Div(res, Fac(n - r));
    return res;
  }
}

class Scanner
{
  string[] s;
  int i;

  char[] cs = new char[] { ' ' };

  public Scanner()
  {
    s = new string[0];
    i = 0;
  }

  public string next()
  {
    if (i < s.Length) return s[i++];
    string st = Console.ReadLine();
    while (st == "") st = Console.ReadLine();
    s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
    if (s.Length == 0) return next();
    i = 0;
    return s[i++];
  }

  public int nextInt()
  {
    return int.Parse(next());
  }
  public int[] ArrayInt(int N, int add = 0)
  {
    int[] Array = new int[N];
    for (int i = 0; i < N; i++)
    {
      Array[i] = nextInt() + add;
    }
    return Array;
  }

  public long nextLong()
  {
    return long.Parse(next());
  }

  public ulong nextULong()
  {
    return ulong.Parse(next());
  }

  public long[] ArrayLong(int N, long add = 0)
  {
    long[] Array = new long[N];
    for (int i = 0; i < N; i++)
    {
      Array[i] = nextLong() + add;
    }
    return Array;
  }

  public double nextDouble()
  {
    return double.Parse(next());
  }


  public double[] ArrayDouble(int N, double add = 0)
  {
    double[] Array = new double[N];
    for (int i = 0; i < N; i++)
    {
      Array[i] = nextDouble() + add;
    }
    return Array;
  }
}


Measured memory_bytes: 11092
n, m = list(map(int, input().split()))
t = [0 for i in range(m+1)]
for i in range(n):
  a = list(map(int, input().split()))
  for j in range(1, len(a)):
    t[a[j]] += 1
ans = 0
for i in range(1, m+1):
  if t[i]==n:
    ans += 1
print(ans)

Measured memory_bytes: 3064
num=[0]*9
used=[0]*10
def check():
    if num[0]+num[2]+num[5]-num[8]+(num[1]+num[4]-num[7])*10+(num[3]-num[6])*100: return 0
    return 1

def dfs(id):
    if id==9:return check()
    if num[id]!=-1:return dfs(id+1)
    ans=0
    for i in range(1,10):
        if used[i]:continue
        num[id]=i;used[i]=1
        ans+=dfs(id+1)
        num[id]=-1;used[i]=0
    return ans

num=list(map(int,input().split()))
for x in num:
    if x!=-1:used[x]=True
print(dfs(0))

Measured memory_bytes: 7784
#include <bits/stdc++.h>
constexpr int MAX = 1<<15;
constexpr int SQRT = 182;
int dp[MAX][5][SQRT+1];
int main(){
	std::fill(dp[0][0],dp[0][0]+SQRT, 1);
	for(int i =1 ; i < MAX; i++){
		for(int k = 1; k <= 4; k++){
			for(int j = 1; j * j <= i; j++){dp[i][k][j] += dp[i-j*j][k-1][j];}
			for(int j = 1; j<= SQRT; j++){dp[i][k][j] += dp[i][k][j-1];}
		}
	}
	for(int N;;){
		std::cin >> N;
		if(N == 0){break;}
		std::cout << dp[N][1][SQRT]+dp[N][2][SQRT]+dp[N][3][SQRT]+dp[N][4][SQRT] << std::endl;
	}
}


Measured memory_bytes: 120208
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
#define MOD 1000000007
int main(){
    ll H,W;
    cin >> H >>W;
    string S[H];
    ll i,j,k;
    for(i=0;i<H;i++){
        cin >> S[i];
    }
    ll cnt,mn;
    ll a[H+1][W+1],b[H+1][W+1];
    for(i=0;i<H;i++){
        cnt=0;
        mn=0;
        for(j=0;j<=W;j++){
            if(j<W&&S[i][j]=='.')cnt++;else{
                for(k=mn;k<j;k++){
                    a[i][k]=cnt;
                }
                a[i][j]=0;
                cnt=0;
                mn=j+1;
            }
        }
    }
    for(j=0;j<W;j++){
        cnt=0;
        mn=0;
        for(i=0;i<=H;i++){
            if(i<H&&S[i][j]=='.')cnt++;else{
                for(k=mn;k<i;k++){
                    b[k][j]=cnt;
                }
                b[i][j]=0;
                cnt=0;
                mn=i+1;
            }
        }
    }
    ll ans=0;
    for(i=0;i<H;i++){
        for(j=0;j<W;j++){
            ans=max(ans,a[i][j]+b[i][j]-1);
        }
    }
    cout << ans;
    return 0;
}


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

int main() {
  int M, D;
  cin >> M >> D;

  long ans{};
  for (int m{1}; m <= M; ++m) {
    for (int d{1}; d <= D; ++d) {
      int d1 = d % 10;
      int d10 = d / 10;
      if (d1 >= 2 && d10 >= 2 && d1 * d10 == m)
        ++ans;
    }
  }

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


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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define MOD 1e9+7
#define sp ' '


using ll = long long;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}

int main(){

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

    int n, a, b;
    cin >> n >> a >> b;

    cout << min(a, b) << sp << max(a+b-n, 0) << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 2000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int a, b;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> a >> b;
    cout << ((b-a) * (b-a+1) / 2) - b << endl;
    return 0;
}


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

long long input(){
  string s;
  cin >> s;
  long long a = 0;
  size_t i = 0;
  for(;i < s.length(); ++i){
    if(s[i] == '.') break;
    a *= 10;
    a += s[i]-'0';
  }
  ++i;
  for(size_t j = 0; j < 9; ++j){
    a *= 10;
    if(i+j < s.length())
      a += s[i+j]-'0';
  }
  return a;
}

int main(){
  int N;
  cin >> N;
  long long ans = 0;
  const int m = 60, M = 2*m+1;
  vector<vector<long long>> C(M,vector<long long>(M));
  
  for(int i = 0; i < N; ++i){
    long long a = input();
    int c2 = -9, c5 = -9;
    // cerr << a << endl;
    while(a%2 == 0) ++c2, a /= 2;
    while(a%5 == 0) ++c5, a /= 5;
    // cerr << c2 << " " << c5 << endl;
    c2 = min(c2,M-1);
    c5 = min(c5,M-1);
    for(int i = -c2+m; i < M; ++i){
      for(int j = -c5+m; j < M; ++j){
        ans += C[i][j];
      }
    }

    ++C[c2+m][c5+m];
  }
  cout << ans << endl;
}


Measured memory_bytes: 3704
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
const int w=3e5+5;
const ll mod=1e9+7;
ll ni[w],fac[w];
ll quick(ll x,ll y)
{
    ll ans=1;
    while(y)
    {
        if(y&1)
            ans=ans*x%mod;
        x=x*x%mod;
        y/=2;
    }
    return ans;
}
ll C(ll n,ll m)
{
    return fac[n]*ni[m]%mod*ni[n-m]%mod;
}
int main()
{
    int i,j;
    ll n,m;
    cin>>n>>m;
    fac[0]=1,fac[1]=1,ni[1]=1,ni[0]=1;
    for(i=2;i<=n;i++)
    {
        fac[i]=fac[i-1]*i%mod;
        //ni[i]=(ll)(mod-mod/i)*ni[mod%i]%mod;
        ni[i]=quick(fac[i],mod-2);
    }
    m=min(m,n-1);
    ll ans=0;
    for(i=0;i<=m;i++)
        ans+=C(n,i)*C(n-1,n-i-1)%mod,ans%=mod;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3840
#include <iostream>
#include <cmath>
#define rep(a,i,n) for(int i=(a);i<(n);i++)
using namespace std;

int main(){
int n,m,flag,sum=0;
cin >> n;
cin >> m;
int a[m];
rep(0,i,m){
	cin >> a[i];
	sum += a[i];
}
if(n>=sum)
	flag = n-sum;
else
	flag = -1;
cout << flag << endl;
}

Measured memory_bytes: 3656
mod = 998244353
n,m,k = map(int,input().split())

fac = [1]*(n+1)
inv = [1]*(n+1)
for i in range(1,n+1):
  fac[i] = (fac[i-1]*i) % mod
inv[n] = pow(fac[n], mod-2, mod)
for i in range(n, 0, -1):
  inv[i-1] = (inv[i]*i) % mod
    
def nCr(n,r):  
  if r < 1:
    return 1
  return (((fac[n] * inv[r])%mod) * inv[n-r]) % mod

ans = 0
for i in range(k+1):  
  tmp = m * pow(m-1,n-i-1,mod) * nCr(n-1,i) % mod     
  ans = (ans + tmp) % mod
  
print(ans)

Measured memory_bytes: 24576
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <random>
#include <chrono>

#define _ << " " <<
#define all(v) v.begin(), v.end()
#define sp(n) fixed << setprecision(n)
#define ff first
#define ss second

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const ll mod = 1e9 + 7;
const double eps = DBL_EPSILON;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n), ans(n);
	for (int& i : a) cin >> i;
	for (int i = 0; i < n; i++) ans[a[i] - 1] = i + 1;
	for (int& i : ans) cout << i << " ";
	cout << endl;
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N = 5010;
const ll M = 210;
inline ll read()
{
  ll p=0; ll f=1; char ch=getchar();
  while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();}
  while(ch>='0' && ch<='9'){p=p*10+ch-'0'; ch=getchar();}
  return p*f;
}
ll a[N],b[N][M]; ll s[N]; ll top; ll sum[N][N]; ll l[N],r[N]; ll pre[N];
int main()
{
  ll n=read(),m=read();

  for(ll i=2;i<=n;i++) a[i] = read();
  for(ll i=1;i<=n;i++) for(ll j=1;j<=m;j++) b[i][j] = read();

  for(ll i=1;i<=m;i++)
  {
    top = 0; s[top] = 0;
    for(ll j=1;j<=n;j++) l[j] = r[j] = 0;
    for(ll j=1;j<=n;j++)
    {
      while(top && b[j][i] > b[s[top]][i]) top--;
      l[j] = s[top] + 1; s[++top] = j;
    }

    top = 0; s[top] = n+1;
    for(ll j=n;j>=1;j--)
    {
      while(top && b[j][i] > b[s[top]][i]) top--;
      r[j] = s[top] - 1; s[++top] = j;
    }

    for(ll j=1;j<=n;j++)
    {
      sum[l[j]][j] += b[j][i];
      sum[j+1][j] -= b[j][i] ;
      sum[l[j]][r[j]+1] -= b[j][i];
      sum[j+1][r[j]+1] += b[j][i];
    }
  }

  for(ll i=2;i<=n;i++) pre[i] = pre[i-1] + a[i];

  ll maxx = 0;
  for(ll i=1;i<=n;i++) for(ll j=1;j<=n;j++)
  {
    sum[i][j] = sum[i][j] + sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1];
      if(i<=j) maxx = max(maxx , sum[i][j] - pre[j] + pre[i]);
  }

  return printf("%lld\n",maxx),0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define per(i, n) for(int i = (n)-1; i >= 0; --i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
#define ppp(a) (cout << (a) << endl); 
#define cop(a) for(auto x:(a)){cout << x << endl;}

using ll = long long;

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

constexpr char sp = ' ';
constexpr char cmm = ',';
constexpr ll MOD = 1e9+7;
constexpr ll Mod = 998244353;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;

inline ll mod(ll a, ll m=MOD){return (a%m+m)%m;}
inline ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
inline ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
inline ll inv(ll n, ll m=MOD){
    ll a = n, b = m, x = 1, y = 0;
    while(b){
        ll t = a/b;
        a -= t*b;
        swap(a, b);
        x -= t*y;
        swap(x, y);
    }
    return mod(a, m); 
}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e, ll m=MOD){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}

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 T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    s<<'[';for(size_t i=0;i<v.size();++i){s << v[i];if(i < v.size()-1) s << ", ";}s<<']';return s;
}
struct __{ __(){ /* cin.tie(0); ios::sync_with_stdio(0); */ cout<<fixed<<setprecision(15); } };

int main(){

    int n;
    int P, Q, i;

    scanf("%d", &n); 
    vector<int> p(n), q(n), a(n);
    iota(a.begin(), a.end(), 1);
    rep(i, n) scanf("%d", &p[i]);
    rep(i, n) scanf("%d", &q[i]);
    

    do{
        if(a == p) P = i;
        if(a == q) Q = i;
        ++i;
    }while(next_permutation(a.begin(), a.end()));

    ppp(abs(P-Q));

    return 0;
}


Measured memory_bytes: 256