akhauriyash/Code-Regression huggingface dataset:
let
  input = readline()
  n = parse(Int, input)
  array = map(x -> parse(Int, x), split(readline()))
  sum = 0
  sign = 0
  min_number = 2^63-1
  for element in array
    if element > 0
      sum += element
      min_number = min(min_number, element)
    else 
      sum += (-element)
      min_number = min(min_number, -element)
      sign += 1
    end
  end

  if sign % 2 ≠ 0
    sum -= 2*min_number
  end 

  println(sum)
end


Measured memory_bytes: 129480
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int O = 0;
		for(int i = 1 ; i <= N ; ++i){
			if(i % 2 == 1){
				O++;
			}
		}
		System.out.println(O* 1.0 / N);
	}
}


Measured memory_bytes: 23760
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,p,c=0,i=0;
    vector<int>v;
    vector<int>v1;
    cin>>n;
    int t=n,x;
    while(t--)
    {
        cin>>x;
        v.push_back(x);
        v1.push_back(x);

    }
    sort(v1.begin(),v1.end());
    while(i<v.size())
    {
        if(v1[i]==v[i])
            c++;
        i++;
    }
    //cout<<c<<endl;
    if(c>=n-2)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    return 0;
}



Measured memory_bytes: 3636
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll INF = 1e9+7;
const int MOD = 1e9 + 7;

string A;
ll N,ans=1;



int main(void) {
	

	cin >> A;

	if (A[0] == 'A')ct('T');
	if (A[0] == 'T')ct('A');
	if (A[0] == 'C')ct('G');
	if (A[0] == 'G')ct('C');

	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;


int main() {
  int X,Y;
  cin >> X;
  Y = pow(X,3);
  cout << Y << endl;
  return 0;
}



Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll one = 1;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    int N, M;
    cin >> N >> M;
    vector<vector<int>> G(N);
    int a, b;
    vector<int> v(N, 0);
    for (int i = 0; i < N + M - 1; i++) {
        cin >> a >> b; a--; b--;
        G[a].push_back(b);
        v[b]++;
    }
    int ind = 0;
    for (int i = 0; i < N; i++) {
        if(v[i] == 0){
            ind = i;
            break;
        }
    }
    queue<int> q;
    vector<int> par(N, 0);
    par[ind] = 0;
    q.push(ind);
    while(!q.empty()) {
        int w = q.front(); q.pop();
        for (int x : G[w]){
            v[x]--;
            if(v[x] == 0){
                q.push(x);
                par[x] = w+1;
            }
        }
    }
    for (int i = 0; i < N; i++) {
        printf("%d\n", par[i]);
    }
    


}

Measured memory_bytes: 9588
#include <iostream>
#include <unordered_map>
#include <vector>
#include <tuple>
 
#define loop(n, i) for(int i=0;i<n;i++)
#define repeat(n) for(int __i=0;__i<n;__i++)
#define loop_from_to(from, to, i) for(int i=from;i<=to;i++)
#define multi_cin(n, array) loop(n,i){cin>>array[i];}
#define assign_if_smaller(var, val) if(var>val)var=val;
#define assign_if_larger(var, val) if(var<val)var=val;

using namespace std;
int x_min, x_max;
int y_min, y_max;
int type;
unordered_map<int, vector<tuple<int, int, int>>> sheets;

void init() {
  x_min = 0; y_min = 0; x_max = 0; y_max = 0;
}

void add_sheet(int x1, int y1, int x2, int y2) {
  assign_if_smaller(x_min, x1);
  assign_if_smaller(y_min, y1);
  assign_if_larger(x_max, x2);
  assign_if_larger(y_max, y2);

  auto t = make_tuple(y1, x2, y2);
  if (sheets.count(x1) == 0) {
    sheets[x1] = {t};
  } else {
    sheets[x1].push_back(t);
  }
}

vector<tuple<int, int, int>>& find_end_points(int x, int y) {
  return sheets[x];
}

void calc_and_output() {
  long area = 0;
  long lines = 0;

  int right_area_end_point[y_max + 1];
  loop(y_max + 1, i) right_area_end_point[i] = -1;

  bool* is_area[2];
  is_area[0] = new bool[y_max + 1];
  is_area[1] = new bool[y_max + 1];
  loop(y_max + 1, i) {
    is_area[0][i] = false;
    is_area[1][i] = false;
  }

  loop(x_max + 1, x_i) {
    // update right_area_end_point
    auto& points = find_end_points(x_i, 0);

    // per point operation
    for (auto&& point : points) {
      int y_i = get<0>(point), x = get<1>(point), y = get<2>(point);

      loop_from_to(y_i, y - 1, p_i) {
        assign_if_larger(right_area_end_point[p_i], x);
      }
    }

    loop(y_max + 1, y_i) {

      // included in some sheets
      if (right_area_end_point[y_i] > x_i) {
        area += 1;
        is_area[x_i % 2][y_i] = true;
      } else {
        is_area[x_i % 2][y_i] = false;
      }

      // line check
      if (type == 2) {
        // left line exists
        if (is_area[(x_i % 2) ^ 1][y_i] != is_area[x_i % 2][y_i]) lines += 1;

        // bottom line exists
        if (
            (y_i == 0 && is_area[x_i % 2][y_i]) ||
            (y_i > 0 && (is_area[x_i % 2][y_i - 1] != is_area[x_i % 2][y_i]))
            )
          lines += 1;
      }
    }

  }

  cout << area << endl;
  if (type == 2) cout << lines << endl;

  delete is_area[0];
  delete is_area[1];
}

int main(int argc, char const* argv[])
{
  while (true) {
    int n; cin >> n >> type;
    if (n == 0 && type == 0) break;

    init();

    repeat(n) {
      int p[4];
      multi_cin(4, p);
      add_sheet(p[0], p[1], p[2], p[3]);
    }

    calc_and_output();
    sheets.clear();
  }
  return 0;
}

Measured memory_bytes: 1796
#include <stdio.h>
int a, b, c, d, e;
int main() {
	scanf("%d%d%d%d", &a, &b, &c, &d);
	while (a > 0 && c > 0) {
		if (e)a -= d;
		else c -= b;
		e = 1 - e;
	}
	if (a <= 0)printf("No\n");
	else printf("Yes\n");
}

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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;

const int N = 510;
const double eps = 1e-6;

int n;
int c[N], s[N], f[N];

int main()
{
    cin >> n;
    for(int i = 1; i < n; i++) cin >> c[i] >> s[i] >> f[i];

    for(int i = 1; i <= n; i++)
    {
        int sum = 0;
        for(int j = i; j < n; j++)
        {
            sum = max(sum, s[j]);
            sum = (sum + f[j] - 1) / f[j] * f[j] + c[j];
        }
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
double dist(double x1, double y1, double x2, double y2) {  // (x1, y1) と (x2, y2) のユークリッド距離
    return sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) );
}
 
int main() {
    ll n;
    cin >> n;
 
    vector<double> x(n), y(n);
    rep(i, n) {
        cin >> x[i] >> y[i];
    }
    
    vl perm(n);
    rep(i, n) {
        perm[i] = i;
    }
    
    double ans = 0.0;
    do {
        // {0, 1, … , n-1} の全順列を昇順に出力
        rep(i, n-1) {
            ans += dist(x[perm[i]], y[perm[i]], x[perm[i+1]], y[perm[i+1]]);
        }
        
    } while(next_permutation(all(perm)));
 
    ll p = 1;
    exrep(i, 1, n) {
        p *= i;
    }
 
    ans /= (double)p;
    
    exout(ans);
    re0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

const int MAXN = 100005;
int visited[MAXN], color[MAXN];

int n, wcnt, bcnt;

vector< vector<int> > adj;

vector<int> path;

bool dfs(int u) {
    visited[u] = 1;
    path.PB(u);

    if (u == n) return true;

    for (auto& v : adj[u]) {
        if (!visited[v]) {
            if (dfs(v)) return true;
        }
    }

    path.pop_back();
    return false;
}

void dfs2(int u, int c) {
    color[u] = c;

    if (c == 0) {
        bcnt++;
    }
    else {
        wcnt++;
    }

    for (auto& v : adj[u]) {
        if (color[v] == -1) {
            dfs2(v, c);
        }
    }
}

int main() {
    GI(n);

    int a, b;

    adj.resize(n+1);

    FORN(i, n-1) {
        GI(a);
        GI(b);

        adj[a].PB(b);
        adj[b].PB(a);
    }

    memset(visited, 0, sizeof visited);

    dfs(1);
//    PR0(path, path.size());

    memset(color, -1, sizeof color);

    bcnt = 0;
    wcnt = 0;
    int curr = 0;

    // Color the path.
    int i = 0;
    int j = path.size() - 1;

    while (i <= j) {
        if (curr == 0) {
            color[path[i]] = curr;
            i++;
        }
        else {
            color[path[j]] = curr;
            j--;
        }
        curr = 1 - curr;
    }

    for (auto& p : path) {
        dfs2(p, color[p]);
    }

//    DEBUG(bcnt);
//    DEBUG(wcnt);

    if (bcnt > wcnt) {
        printf("Fennec\n");
    }
    else {
        printf("Snuke\n");
    }

    return 0;
}

Measured memory_bytes: 11640
//Volume0-0031
import java.util.Scanner;

class Main {

    public static void main(String[] arg){

        //declare
    	int       n,w;
    	boolean   flg;
    	boolean[] table;

        //input
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
        	n = sc.nextInt();

        	//calculate
        	table = new boolean[10];
        	w = 512;
        	for(int i=9;i>=0;i--){
        		if(n - w >= 0){
        			n -= w;
        			table[i] = true;
        		}
        		w/=2;
        	}

        	//output
        	flg = false;
        	for(int i=0;i<10;i++){
        		if(table[i]){
        			if(flg){
        				System.out.print(" ");
        			}
        			System.out.print((int)Math.pow(2,i));
        			flg = true;
        		}
        	}
        	System.out.println();
        }
    }
}

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

int main(){
  int A,B;
  cin>>A>>B;
  if(A==1){
    A=14;
  }
  if(B==1){
    B=14;
  }
  
  if(A>B){
    cout<<"Alice"<<endl;
  }else if(A<B){
    cout<<"Bob"<<endl;
  }else{
    cout<<"Draw"<<endl;
  }
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.awt.Point;
public class Main {
	static Scanner sc;
	static PrintWriter out;
	static final int uncal = -1;
	static final double pi = 3.14159;
	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		sc = new Scanner(System.in); 
		out = new PrintWriter(System.out);
		int n = sc.nextInt();
		int m = sc.nextInt();
		long sum = 0l;
		for(int i=0;i<m;i++) {
			sum	+= sc.nextInt();
		}
		if(n<sum) {
			out.println(-1);
		}else {
			out.println(n-sum);
		}
		out.close();
	}
	static void shuffle(int[] array) {
		Random rand = new Random();
		for (int i = 0; i < array.length; i++) {
			int randomIndexToSwap = rand.nextInt(array.length);
			int temp = array[randomIndexToSwap];
			array[randomIndexToSwap] = array[i];
			array[i] = temp;
		}
	}
	static boolean isPalindrome(String s) {
		int l = s.length();
		char[] sa = s.toCharArray();
		for(int i=0;i<l/2;i++) {
			if(sa[i] != sa[l-i-1])
				return false;
		}
		return true;
	}
	static class Point extends java.awt.Point implements Comparable<Point>{
		public Point(int x,int y) {
			// TODO Auto-generated constructor stub
			super(x,y);
		}
		public String toString() {
			return x+" "+y;
		}
		@Override
		public int compareTo(Point p) {
			// TODO Auto-generated method stub
			if(x == p.x)
				return y - p.y;
			return x - p.x;
		}
		
	}
	static class Scanner{
		private BufferedReader br;
		private StringTokenizer st;
		public Scanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
		}
		public Scanner(String filename) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(filename));
		}
		public String next() throws IOException{
			while(st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
		public int nextInt() throws IOException{
			return Integer.parseInt(next());
		}
		public long nextLong() throws IOException{
			return Long.parseLong(next());
		}
		public double nextDouble() throws IOException{
			return Double.parseDouble(next());
		}
		public int[] inArr(int n) throws Exception{
			int a [] = new int[n];
			st = new StringTokenizer(br.readLine());
			for(int i=0;i<n;i++) {
				a[i] = Integer.parseInt(next());
			}
			return a;
		}
	}

}

Measured memory_bytes: 33936
#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <ctime>
#include <string>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
//#include <random>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
#define PB push_back
#define MP make_pair
#define INF 1073741824
#define inf 1152921504606846976
#define pi 3.14159265358979323846
//#pragma comment(linker,"/STACK:10240000,10240000")
//mt19937 rand_(time(0));
const int N=3e5+7,M=2e6;
const long long mod=1e9+7;
inline int read(){int ret=0;char ch=getchar();bool f=1;for(;!isdigit(ch);ch=getchar()) f^=!(ch^'-');for(;isdigit(ch);ch=getchar()) ret=(ret<<1)+(ret<<3)+ch-48;return f?ret:-ret;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll ksm(ll a,ll b,ll mod){int ans=1;while(b){if(b&1) ans=(ans*a)%mod;a=(a*a)%mod;b>>=1;}return ans;}
ll inv2(ll a,ll mod){return ksm(a,mod-2,mod);}//逆元
//int head[N],NEXT[M],ver[M],tot;void link(int u,int v){ver[++tot]=v;NEXT[tot]=head[u];head[u]=tot;}


ll res[60][60];
ll ans[60][60],tmp[60][60];
int n;
void mul(ll a[][60],ll b[][60]){
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            tmp[i][j]=0;
            for(int k=1;k<=n;k++){
                tmp[i][j]+=a[i][k]*b[k][j];
                tmp[i][j]%=mod;
            }
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            a[i][j]=tmp[i][j];
        }
    }
}
void Pow(ll x){
    while(x){
        if(x%2==0){
            mul(res,res);
            x/=2;
        }
        else {
            mul(ans,res);
            x--;
        }
    }
}
int main(){
    //freopen("1.txt","r",stdin);
    //ios::sync_with_stdio(false);
    ll k;
    scanf("%d%lld",&n,&k);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            scanf("%lld",&res[i][j]);
        }
        ans[i][i]=1;
    }
    Pow(k);
    ll ANS=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            ANS+=ans[i][j];
            ANS%=mod;
        }
    }
    printf("%lld\n",ANS);
    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}




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

void solve(long long N, long long T, vector<long long> t){
	long long res = 0;
	long long s = 0;
	for(int i = 0; i < N; ++i) {
		if(s + T >= t[i]) {
			res += t[i] - s;
		} else {
			res += T;
		}
		s = t[i];
	}
	res += T;
	cout << res << endl;
}

int main(){	
	long long T;
	long long N;
	scanf("%lld",&N);
	vector<long long> t(N-1+1);
	scanf("%lld",&T);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&t[i]);
	}
	solve(N, T, t);
	return 0;
}



Measured memory_bytes: 3328
from math import factorial

N = int(input())
A = input().split()

L = [0 for i in range(N)]

for i in range(N):
  L[int(A[i])-1] +=1

c = 0
for i in range(N):
  n = L[i]
  if n >= 2:
    c += factorial(n) // factorial(2) // factorial(n - 2)

for i in range(N):
  n = L[int(A[i])-1]
  if n >= 2:
    print(c - n + 1)
  else:
      print(c)

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

int main(){
  int n; cin >> n;
  vector<string> s;
  
  for(int i=0; i<n; ++i){
	  string k;
	  cin >> k;
	  s.push_back(k);
  }
  sort(s.begin(), s.end());

  s.erase(unique(s.begin(), s.end()), s.end());
  cout << s.size() << endl;
  
}

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

int main(){
	int n;
	cin >> n;
	vector<int> w(n);
	int sum = 0;
	rep(i, n){
		cin >> w.at(i);
		sum += w.at(i);
	}

	int diff = sum;
	int leave;
	int acc = 0;
	rep(i, n){
		acc += w.at(i);
		leave = sum - acc;
		diff = min(diff,abs(acc - leave));
	}

	cout << diff << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

//B - Frog 2
//simple dp
//build your logic

//https://atcoder.jp/contests/dp/tasks/dp_b

public class Main {
    static StringTokenizer st;
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

 
    public static void main(String[] args) throws IOException {
  
        int N = nextInt();
        int K = nextInt();
        int dp[] = new int[N+1];

        int input[] = new int[N+1];


        for (int i=1; i<=N;  i++) {
            input[i] = nextInt();
        }

        // now dp time
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[1] = 0;
        for (int i=1; i<=N;  i++) {
            for (int j=1; j<=K;  j++) {
                if(i+j<=N){
                    dp[i+j] = Math.min(dp[i+j], dp[i] + Math.abs(input[i+j]- input[i]));
                }
            }
        }

        System.out.println(dp[N]);
    }
    

    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
}

Measured memory_bytes: 32908
def solve(nums):
  curr_min = 2 * 10**5 + 1
  ans = 0
  for n in nums:
    if n <= curr_min:
      ans += 1
    curr_min = min(curr_min, n)
  print(ans)

  
def iin(): return int(input())
def iln(): return list(map(int, input().split()))


N = iin()
nums = iln()
solve(nums)

Measured memory_bytes: 24744
a, b, k = list(map(int, input().split()))

ans_l = []
for i in range(k):
    if b >= a+i:
        ans_l.append(a+i)

for i in reversed(range(k)):
    if a <= b-i:
        ans_l.append(b-i)
    
ans_l = sorted(list(set(ans_l)))
for i in range(len(ans_l)):
    print(ans_l[i])



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

using namespace std;

// ABC051-C - Back and Forth
int main()
{
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    string output;

    // S->T
    for (int y = sy; y < ty; y++) output.append("U");
    for (int x = sx; x < tx; x++) output.append("R");

    // T->S
    for (int y = ty; y > sy; y--) output.append("D");
    for (int x = tx; x > sx; x--) output.append("L");

    // S->T
    output.append("L");
    for (int y = sy; y < ty + 1; y++) output.append("U");
    for (int x = sx - 1; x < tx; x++) output.append("R");
    output.append("D");

    // S->T
    output.append("R");
    for (int y = ty; y > sy - 1; y--) output.append("D");
    for (int x = tx + 1; x > sx; x--) output.append("L");
    output.append("U");

    cout << output << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N;
    ll K;
    cin >> N >> K;
    vector<ll> A(N), F(N);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> F[i];

    sort(all(A));
    sort(all(F));
    reverse(all(F));

    ll ng = -1, ok = 1e18;
    while (ok - ng > 1) {
        ll mid = (ng + ok) / 2;

        ll k = 0;
        rep(i, N) {
            k += max(A[i] - mid / F[i], 0LL);
        }

        if (k <= K) ok = mid;
        else ng = mid;
    }
    write(ok);
}

Measured memory_bytes: 3328
///age yekam bekeshi beham is no problem ._.
#include<bits/stdc++.h>
#define size(a) (int)a.size()
#define ld long double
#define int long long
#define F first
#define S second
#define pb push_back
using namespace std;
void null(){return ;}
const int maxn=1e5+7,INF=3e18+9237,mod=1e9+7;

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

int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n,x;cin>>n>>x;
	cout<<3*(n-gcd(n,x));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// #include"prettyprint.hpp"
typedef long long ll;
typedef double db;

#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const ll LINF = LLONG_MAX, MOD = 1e9 + 7, N = 1e5 + 5, LG = 20;
const int INF = INT_MAX;
const db PI = acos(-1), EPS = 1 / db(1e6);

void test() {
    int r, c, k; cin >> r >> c >> k;
    char a[r][c];
    for (int i = 0; i < r; ++i) {
        for (int j = 0; j < c; ++j) {
            cin >> a[i][j];
        }
    }
    // debug(arr(a, r, c));
    int ans = 0;
    for (int l = 0; l < pow(2, r); ++l) {
        for (int m = 0; m < pow(2, c); ++m) {
            // To make the temporary array copying the original array
            char temp[r][c];
            for (int i = 0; i < r; ++i) {
                for (int j = 0; j < c; ++j) {
                    temp[i][j] = a[i][j];
                }
            }
            bitset<6> row(l);
            bitset<6> col(m);
            // Making the rows red
            for (int i = 0; i < r; ++i) {
                if (row[i]) {
                    for (int j = 0; j < c; ++j) temp[i][j] = 'R';
                }
            }
            // making the columns red
            for (int i = 0; i < c; ++i) {
                if (col[i]) {
                    for (int j = 0; j < r; ++j) temp[j][i] = 'R';
                }
            }
            // to find how many of them are black
            int mid_ans = 0;
            for (int i = 0; i < r; ++i) {
                for (int j = 0; j < c; ++j) {
                    if (temp[i][j] == '#') ++mid_ans;
                }
            }
            if (mid_ans == k) ++ans;
        }
    }
    cout << ans << "\n";
}

int main() {
      fast_io();
      #ifdef HOME
            freopen("input.txt", "r", stdin);
            freopen("output.txt", "w", stdout);
      #endif
      cout << fixed << setprecision(15);
      int t = 1;
      // cin >> t;
      for (int i = 1; i <= t; ++i) {
          test();
      }
      #ifdef HOME
          cout << "Time: " << (int)(clock() * 1000. / CLOCKS_PER_SEC) << "ms";
      #endif
      return 0;
}


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

long combi(int n, int r) {
    if (r == 0) {
        return 1;
    }
    
    return (n - r + 1) * combi(n, r - 1) / r;
}

int main(void){
    
    int N,M;
    cin >> N >> M;
    cout << combi(N,2) + combi(M,2) << endl;    
}

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

int n;
vector<vector<int>> a(100,vector<int>(100, -1));
vector<int> t, d(100, -1);

void prim(int start) {
    t.push_back(start);
    d[start] = 0;
    while (t.size() < n) {
        int min_v = 2001, min_i;
        rep(i, t.size()) {
            rep(j, n) {
                if (a[t[i]][j] != -1 && d[j] == -1 && a[t[i]][j] < min_v) {
                    min_v = a[t[i]][j];
                    min_i = j;
                }
            }
        }
        t.push_back(min_i);
        d[min_i] = min_v;
    }
    
}

int main() {
    scanf("%d", &n);
    rep(i, n) {
        rep(j, n) {
            scanf("%d", &a[i][j]);
        }
    }
    prim(0);
    int sum = 0;
    rep(i, n) {
        sum += d[i];
    }
    printf("%d\n", sum);
}


Measured memory_bytes: 3340
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int main() {
  ll n; cin >>n;
  ll res = 0;
  for (int i=1; i<=n; i++){
    if (i % 3 == 0) continue;
    if (i % 5 == 0) continue;
    res += i;
  }
  cout <<res <<endl;
}


Measured memory_bytes: 3596
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int seki = a * b;
    if(seki % 2 == 1){
      System.out.println("Odd");
    }else{
      System.out.println("Even");
    }
  }
}

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

int main(){
  long long int a,b;
  string op;
  cin >> a >> op >> b;
  
  if(op == "+") cout << a+b << endl;
  if(op == "-") cout << a-b << endl;
}

Measured memory_bytes: 256
import collections

N = int(input())
A = list(map(int, input().split()))
Q = int(input())
BC = [list(map(int, input().split())) for _ in range(Q)]

cnt_list = collections.Counter(A)
total = sum(A)
for i in range(Q):
    cnt_list[BC[i][1]] += cnt_list[BC[i][0]]
    total += (BC[i][1] - BC[i][0]) * cnt_list[BC[i][0]]
    cnt_list[BC[i][0]] = 0
    print(total)


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

vector<int> sieve(int n) {
  vector<int> prime(n);
  for(int i=2; i<n; i++) prime[i]=i;
  for(int i=2; i*i<n; i++) {
    if(prime[i])  {
      for(int j=i*i; j<n; j+=i) prime[j]=0;
    }
  }

  return prime;
}

int main() {
  int n;
  vector<int> prime;
  prime = sieve(50022);

  while(cin >> n) {
    int count=0;
    vector<int>::iterator it;

    for(int i=n-1; i>=2; i--) {
      if(prime[i]!=0) {
	cout << i << " ";
	break;
      }
    }
    for(int i=n+1; i<50022; i++) {
      if(prime[i]!=0) {
	cout << i <<endl;
	break;
      }
    }
  }
  return 0; 
}


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

int main() {
    int a, b, c, d;  cin >> a >> b >> c >> d;
    bool turn = true;
    while (true) {
        if (turn) {
            c -= b;
            if (c <= 0) {
                cout << "Yes" << endl;
                return 0;
            }
        }
        else {
            a -= d;
            if (a <= 0) {
                cout << "No" << endl;
                return 0;
            }

        }
        turn = 1 - turn;
    }
}


Measured memory_bytes: 3600
import random
class Dice:
    def __init__(self, dice):
        self.dice = dice
        self.rule={'N':(1,5,2,3,0,4),'S':(4,0,2,3,5,1),'E':(3,1,0,5,4,2),'W':(2,1,5,0,4,3)}
    def output(self):
        return self.dice
    def move(self, direction):
        for _ in direction: self.dice = [self.dice[y] for y in self.rule[_]]
        return self.dice

dice_1 = Dice([int(x) for x in input().split()])
dice_2 = Dice([int(x) for x in input().split()])

Dir = 'NSEW'

for _ in range(10000):
    dice_2.move(Dir[random.randint(0,3)])
    if dice_1.output() == dice_2.output(): break

print('No') if _ == 9999 else print('Yes')


Measured memory_bytes: 8180
import scala.io.{StdIn => in}

object Main extends App {
  val s = in.readLine
  val n = s.size
  val v = "keyence"

  val res = for {
    i <- 0 to n
    j <- 0 to n
    if s.take(i) + s.drop(j) == v
  } yield true

  val ans = if(res.nonEmpty) "YES" else "NO"
  println(ans)
}

Measured memory_bytes: 32300
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


ll E[100][100];

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


  rep(i,100)rep(j,100) E[i][j] = 100000;
  
  ll N , M ; cin >> N >> M ;
  vector<pair<pair<ll,ll> , ll> > abc;
  
  rep(i,M){
    ll a,b,c; cin >> a >> b >> c ;
    a--; b--;
    E[a][b] = c;
    E[b][a] = c;
    
    abc.pb(mp(mp(a,b),c));
  }

  
  rep(k,N)rep(i,N)rep(j,N)
    E[i][j] = min(E[i][j], E[i][k]+E[k][j]);



  ll ans = 0;
  rep(i, abc.size()){
    ll a = abc[i].first.first;
    ll b = abc[i].first.second;
    ll c = abc[i].second;

    if(E[a][b] != c) {ans ++;}
  }
  

  cout << ans << endl;

  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>

using namespace std;

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

	vector<vector<int>> a(n,vector<int>(m));
	vector<int> b(m);

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < m; i++) {
		cin >> b[i];
	}

	vector<int> c(n);
	for (int i = 0; i < n; i++) {
		int sum = 0;
		for (int j = 0; j < m; j++) {
			sum += a[i][j] * b[j];
		}
		c[i] = sum;
	}

	for (int x : c) {
		cout << x << endl;
	}
	return 0;
}


Measured memory_bytes: 3168
//id:miiifa (AOJ,PEどちらも)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF= 1LL << 60;
#define REP(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)
// #ifdef DEBUG 
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    const char LF = '\n';
    stack<string> A;
    string x;
    int first, second;
    while(cin >> x) {
        if(x=="+"||x=="-"||x=="*"){
            second= stoi(A.top());
            A.pop();
            first= stoi(A.top());
            A.pop();
            if(x=="+"){
                A.push(to_string(first+second));
            } else if(x=="-"){
                A.push(to_string(first-second));
            } else if(x=="*"){
                A.push(to_string(first*second));
            }
        } else{
            // cout << x;
            // if() break;
            A.push(x);
        } 
    }
    string ans= A.top();
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3280
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

// DP
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; }




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

ll N, M, Q;
vector<tuple<ll, ll, ll, ll>> tpl;

ll ans = 0;

ll calc(vector<ll> A){
    ll ret = 0;
    for(auto& [a, b, c, d]: tpl){
        if (A[b] - A[a] == c) ret += d;
    }
    return ret;
}

void rec(ll idx, vector<ll> vec){
    if (idx == N){
        chmax(ans, calc(vec));
        return;
    }

    ll begin;
    if (idx == 0) begin = 1;
    else begin = vec[idx - 1];
    FOR(i, begin, M + 1){
        vec[idx] = i;
        rec(idx+1, vec);
    }
}

int main(){
    cin >> N >> M >> Q;
    REP(i, Q){
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        a--; b--;
        tpl.push_back({a, b, c, d});
    }

    vector<ll> vec(N);
    rec(0, vec);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3612
h, w = gets.split.map(&:to_i)
w+=1

s = readlines.map(&:bytes)

a = Array.new(h+1) { Array.new(w+1,0) }
blockers=Array.new(w+1) { Array.new }

h.times do |i|
  l=0
  w.times.select {|j| s[i][j]!=46 }.each do |j|
    blockers[j] << i
    l.upto(j-1) {|c_j| a[i][c_j] = j-l }
    l=j+1
  end
end

w.times { |k| blockers[k] << h }

blockers.each_with_index do |blocks, height|
  l=0
  blocks.each do |b|
    l.upto(b-1) {|j| a[j][height] += b-l }
    l = b+1
  end
end

p a.map(&:max).push(1).max-1


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

using namespace std;

void solve() {
    int N, M;
    cin >> N >> M;
    vector<int> L(M, 0);
    for (int i = 0; i < M; i++) {
        int k, s;
        cin >> k;
        for (int j = 0; j < k; j++) {
            cin >> s;
            L[i] |= (1 << (s-1));
        }
    }
    vector<int> p(M);
    for (int i = 0; i < M; i++) {
        cin >> p[i];
    }
    
    int ans;
    ans = 0;
    for (int bit = 0; bit < (1<<N); ++bit) {
        bool ok = true;
        for (int i = 0; i < M; i++) {
            if(__builtin_popcount(bit & L[i]) % 2 != p[i]){
                ok = false;
            }
        }
        if(ok) {
            ans ++;
        }
    }
    
    cout << ans << endl;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int N, M, K;
string S, T;
int P;

struct ed
{
    int from, to, cost;
};
vector<ed> edges;

//=============================
void input()
{
    cin >> N >> M >> P;
    edges.resize(M);
    rep(i, 0, M - 1)
    {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        edges[i].from = a;
        edges[i].to = b;
        edges[i].cost = c - P; // 最長経路問題
        edges[i].cost *= -1;   // 最短経路問題. 負の辺あり
    }
}
//=============================
void func() {}
/*
 - 樹形図をかく
*/
//=============================

void dfs(vector<int> v[], int from, bool visit[])
{
    if (visit[from])
        return;
    visit[from] = true;
    for (int u : v[from])
    {
        dfs(v, u, visit);
    }
}

bool reachable1[2505];
bool reachable2[2505];
vector<int> to[2505];
vector<int> ot[2505];
void solve()
{
    for (auto x : edges)
    {
        int a, b;
        a = x.from;
        b = x.to;
        to[a].push_back(b);
        ot[b].push_back(a);
    }

    dfs(to, 0, reachable1);
    dfs(ot, N - 1, reachable2);

    // 負の閉路が存在する場合  -1を出力
    // Bellman-Ford algorithm

    vector<int> dist(N, INF);
    dist[0] = 0;
    bool negloop = false;
    int step = 0;
    for (; step <= N; ++step)
    {
        for (auto e : edges)
        {
            if (dist[e.from] == INF)
            {
                continue;
            }
            if (reachable1[e.from] && reachable2[e.from] == false)
                continue;
            if (reachable2[e.to] && reachable2[e.to] == false)
                continue;
            else
            {
                dist[e.to] = min(dist[e.to], dist[e.from] + e.cost);
            }
        }
    }
    for (auto e : edges)
    {
        if (reachable1[e.from] && reachable2[e.from] == false)
            continue;
        if (reachable2[e.to] && reachable2[e.to] == false)
            continue;
        if (dist[e.from] == INF)
            continue;
        if (dist[e.from] + e.cost < dist[e.to])
            negloop = true;
    }

    cout << (negloop ? -1LL : max(0LL, dist[N - 1] * (-1))) << endl;
}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  int v[4][3][10] = {0};
  for (int i = 0; i < n; i++) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    --a, --b, --c;
    v[a][b][c] += d;
  }
  for (int i = 0; i < 4; i++) {
    if (i > 0) cout << "####################" << endl;
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 10; k++) cout << ' ' << v[i][j][k];
      cout << endl;
    }
  }
}



Measured memory_bytes: 3072
#include <iostream>
#include <algorithm>

using namespace std;

int partition(int A[], int p, int r) {
	int x = A[r];
	int i = p;

	for (int j = p; j < r; j++) {
		if (A[j] <= x) {
			swap(A[i++], A[j]);
		}
	}
	swap(A[i], A[r]);

	return i;
}

int main() {
	int n;
	cin >> n;
	int A[n], suffix;

	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	suffix = partition(A, 0, n - 1);

	for (int i = 0; i < n; i++) {
		if (i == suffix) {
			cout << "[" << A[i] << "]";
		}
		else {
			cout << A[i];
		}

		if (i < n - 1) {
			cout << " ";
		}
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 1548
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <queue>

using namespace std;
#define long long long

const int N = 1e6;

typedef priority_queue<int> HeapMax;
typedef priority_queue<int, vector<int>, greater<int> > HeapMin;
int n;
long b, sp, ss;
HeapMax Pre;
HeapMin Suf;

void Type_1()
{
    int x, y;
    scanf("%d%d", &x, &y); b+=y;
    if (!sp) {Pre.push(x); sp += x; return;}

    if (x <= Pre.top()) {Pre.push(x); sp += x;}
    else {Suf.push(x); ss += x;}
}

void Type_2()
{
    int num = Pre.size() + Suf.size();
    while (Pre.size() > (num + 1) / 2) {
        int tmp = Pre.top();
        sp -= tmp, ss += tmp;
        Pre.pop(), Suf.push(tmp);
    }
    while (Pre.size() < (num + 1) / 2) {
        int tmp = Suf.top();
        ss -= tmp, sp += tmp;
        Suf.pop(); Pre.push(tmp);
    }

    int tmp = Pre.top();
    long res = ((long) tmp * (int)Pre.size()) - sp + ss -  ((long)tmp * (int)Suf.size());
    res += b;
    printf("%d %lld\n", tmp, res);
}

int main()
{
//    freopen("tam.inp", "r", stdin);
    scanf("%d", &n);
    for (int i = 0, type; i < n; ++i) {
        scanf("%d", &type);
        if (type == 1) Type_1();
        else Type_2();
    }
    return 0;
}


Measured memory_bytes: 3452
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int a, b;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> a >> b;
	if(b >= a) cout << a << "\n";
	else cout << a - 1 << "\n";
	return 0;
}

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

int n;
int M[101010]={};
ll dp[101010]={};
ll cnt=0;


int main(){
   int k;
   cin>>n>>k;
   rep(i,n){
     cin>>M[i];
   }
   dp[0]=0;
   dp[1]=abs(M[0]-M[1]);
   rep(i,n-2){
      dp[i+2]=LLONG_MAX;
      rep(j,k){
         if(i-j+1<0)break;
         dp[i+2]=min(dp[i+2],abs(M[i-j+1]-M[i+2])+dp[i-j+1]);
      }
   }
   cout<<dp[n-1]<<endl;
   return 0;
}



Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdio>
#include <set>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
const int maxn=1000010;
int G[maxn][26];
bool flg[maxn];
int n,ans,nxt=1;
int main(){
	cin>>n;
	vector<string>in(n);
	vector<vector<int> >p(n);
	for(int sta=0;sta<n;sta++){
		cin>>in[sta];
		string&s=in[sta];
		reverse(s.begin(),s.end());
		int node=0;
		for(char ch:s){
			int x=ch-'a';
			p[sta].pb(node);
			if(G[node][x]==0)G[node][x]=nxt++;
			node=G[node][x];
		}
		flg[node]=1;
	}
	for(int sta=0;sta<n;sta++){
		set<int>lst;
		string&s=in[sta];
		for(int i=(int)s.length()-1;i>=0;--i){
			int node=p[sta][i];
			lst.insert(s[i]);
			for(char ch:lst)ans+=flg[G[node][ch-'a']];
		}
	}
	cout<<ans-n<<endl;
}


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

int main(){
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll MAX = LLONG_MIN;
  MAX = max(MAX, a * c);
  MAX = max(MAX, a * d);
  MAX = max(MAX, b * c);
  MAX = max(MAX, b * d);
  cout << MAX << endl;
}


Measured memory_bytes: 3632
import java.util.*;
import java.io.IOException;
import java.math.*;
public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
    	int n = sc.nextInt();
    	int K = sc.nextInt();
    	int[] listA = new int[K];
    	int[] listB = new int[K];
    	for(int i = 0; i < K; i++) {
    		listA[i] = sc.nextInt();
    		listB[i] = sc.nextInt();
    	}
    	
    	long[][] dp = new long[n][27];
    	IN:for(int i = 0; i < n; i++) {
    		if(i == 0) {
    			for(int j = 0; j < K; j++) {
    				if(1 == listA[j]) {
    					int k = listB[j]-1;
    					dp[0][k] = 1;
    					continue IN;
    				}
    			}
    			for(int j = 0; j < 3; j++) {
    				dp[0][j] = 1;
    			}
    			continue IN;
    		}
    		if(i == 1) {
    			for(int j = 0; j < K; j++) {
    				if(2 == listA[j]) {
    					int tmp = listB[j]-1;
    					for(int k = 0; k < 9; k++) {
    						if(k % 3 == tmp) {
    							dp[1][k] = dp[0][k/3];
    						}
    					}
    					continue IN;
    				}
    			}
    			for(int j = 0; j < 9; j++) {
    				dp[1][j] = dp[0][j/3];
    			}
    			continue IN;
    		}
    		for(int j = 0; j < K; j++) {
    			if(i+1 == listA[j]) {
    				for(int k = 0; k < 27; k++) {
    					if(k % 3 == listB[j]-1 && !(k%3 == (k%9)/3 && (k%9)/3 == k/9)) {
    						dp[i][k] += dp[i-1][(k/9)*3 + (k%9)/3] + dp[i-1][9 + (k/9)*3 + (k%9)/3] + dp[i-1][18 + (k/9)*3 + (k%9)/3];
    						dp[i][k] %= 10000;
    					}
    				}
    				continue IN;
    			}
    		}
    		for(int k = 0; k < 27; k++) {
				if(!((k%3) == (k%9)/3 && (k%9)/3 == k/9)) {
					dp[i][k] += dp[i-1][(k/9)*3 + (k%9)/3] + dp[i-1][9 + (k/9)*3 + (k%9)/3] + dp[i-1][18 + (k/9)*3 + (k%9)/3];
					dp[i][k] %= 10000;
				}
			}
    	}
    	int sum = 0;
    	for(int i = 0; i < 27; i++) {
    		sum += dp[n-1][i] % 10000;
    		sum %= 10000;
    	}
    	System.out.println(sum);
    }
}

Measured memory_bytes: 20164
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

long long calc(long long A) {
    int digit = 40;
    long long ret = 0;
    for(int i = 2; i <= digit; i++) {
        long long temp = pow(2, i);
        long long res = (A) % temp;
        
        //cout << A << "->" <<  i << ", " << res << "," << pow(2,i-1) << endl;
        if (res < pow(2, i-1)) continue;
        else {
            if(res % 2 == 0) ret += pow(2,i-1);
            else continue;
        }
    }
    if ((A)%4 == 1 || (A)%4 == 2) ret += 1;

    return ret;
}

int main () {
    long long A, B;
    cin >> A >> B;      
    //cout << calc(A) << endl;
    cout << (calc(A-1)^calc(B)) << endl;
}

Measured memory_bytes: 256