akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rrep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define maxe(x) *max_element(all(x))
#define mine(x) *min_element(all(x))
#define Size(x) ((int)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo,gyakugen
//mint,dijkstra

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll n;
        cin>>n;
        vl B(n-1);
        rep(i,n-1)cin>>B[i];
        ll res=B[0]+B[n-2];
        rep(i,n-2){
            res+=min(B[i],B[i+1]);
        }
        cout<<res<<endl;
    }

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass : Scanner
{
    static void Main()
    {
        string S = RString();
        var K = RLong();
        if (S.Length >= K)
        {
            for (int i = 0; i < K; i++)
            {
                if (S[i] != '0'+1)
                {
                    WriteLine(S[i]);return;
                }
                else if (i == K - 1)
                {
                    WriteLine(S[i]);return;
                }
            }
        }
        else
        {
            for (int i = 0; i < S.Length; i++)
            {
                if (S[i] != '0'+1)
                {
                    WriteLine(S[i]);
                    return;
                }
            }
        }
    }
}

class Scanner
{
    public static int RInt() => int.Parse(Console.ReadLine());
    public static long RLong() => long.Parse(Console.ReadLine());
    public static string RString() => Console.ReadLine();
    public static double RDouble() => double.Parse(Console.ReadLine());

    public static int[] RInts() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    public static int[] RInts(Func<string, int> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static long[] RLongs() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
    public static long[] RLongs(Func<string, long> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static double[] RDoubles() => Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
    public static double[] RDoubles(Func<string, double> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static string[] RStrings() => Console.ReadLine().Split();
    //public static string[] RStrings(Func<string, string> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static T1 ReadStream<T1>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        return r1;
    }
    public static (T1, T2) ReadStream<T1, T2>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        return (r1, r2);
    }
    public static (T1, T2, T3) ReadStream<T1, T2, T3>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        return (r1, r2, r3);
    }
    public static (T1, T2, T3, T4) ReadStream<T1, T2, T3, T4>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[0], typeof(T3));
        var r4 = (T4)Convert.ChangeType(r[0], typeof(T4));
        return (r1, r2, r3, r4);
    }
}

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

n, m = map(int, input().split())
range_lr = []
for i in range(m):
    l, r = map(int, input().split())
    range_lr.append([l,r])

sidel = 1
sider = n
for lr in range_lr:
    sidel = max(sidel, lr[0])
    sider = min(sider, lr[1])
print(sider-sidel+1 if sider-sidel>=0 else 0)

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

#define LL long long int


int factor_pairs(int n){
    LL ans=1;
    int c=1;
    while(n % 2==0){
        n /= 2;
        c++;
    }
    ans *= c; c=1;

    for(int i=3; i*i<= n; i += 2){
        while(n % i==0){
            n /= i;
            c++;
        }
       ans *= c; c = 1;
    }
    if(n>2) ans *= 2;

return ans ;
}


void solve(int n){
    LL ans = 0;
    for(int c = 1; c< n; ++c){
        ans += factor_pairs(n-c);
    }

    cout<< ans<< endl;
}


int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
    int n; cin>>n;
    solve(n);


}

Measured memory_bytes: 3656
n = int(input())

l = []
for i in range(n):
    tmp = list(input())
    tmp.sort()
    tmp = ''.join(tmp)
    l.append(tmp)

from collections import Counter
c = Counter(l)
num = list(c.values())

from math import factorial
def combinations_count(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))

ans = 0
for i in num:
    if i > 1:
        ans += combinations_count(i, 2)

print(ans)


Measured memory_bytes: 19760
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		long ans = 0;
		Long[] t = new Long[n];
		for (int i = 0; i < n; i++) {
			t[i] = scan.nextLong();
		}
		if (n == 1) {
			System.out.println(t[0]);
			return;
		}
		Arrays.sort(t, Comparator.reverseOrder());
		ans = lcm(t[0], t[1]);
		for (int i = 2; i < n; i++) {
			ans = lcm(ans, t[i]);
		}
		System.out.println(ans);
	}
	public static long gcd(long a, long b) {
		long temp;
		while (a % b != 0) {
			temp = b;
			b = a % b;
			a = temp;
		}
		return b;
	}
	public static long lcm(long a, long b) {
		long g = gcd(a, b);
		return a / g * b;
	}
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3
#define mod 1000000007

struct state{
  int x,y,t,d;
};

bool operator<(const state& a,const state& b){
  return a.d > b.d;
}

int sx,sy,gx,gy;
int n;
bool dame[202][202];
int dist[202][202][6];
int lx,ly;

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

int main(){
  cin>>sx>>sy>>gx>>gy;
  cin>>n;
  rep(i,n){
    int x,y;
    cin>>x>>y;
    x+=100;
    y+=100;
    dame[x][y]=true;
  }
  cin>>lx>>ly;

  priority_queue<state> que;
  que.push((state){sx+100,sy+100,0,0});
  rep(i,202)rep(j,202)rep(k,6)dist[i][j][k]=INF;
  while(que.size()){
    state s=que.top(); que.pop();
    if(dist[s.x][s.y][s.t]!=INF)continue;
    dist[s.x][s.y][s.t]=s.d;
    int sd=((int)abs((s.x-100)*(s.y-100)*s.t))%6;
    rep(dir,6){
      int nx=s.x+dx[dir],ny=s.y+dy[s.x%2][dir];
      int rx=nx-100,ry=ny-100;
      if(abs(rx)>lx||abs(ry)>ly||dame[nx][ny])continue;
      que.push((state){nx,ny,(s.t+1)%6,s.d+(sd!=dir?1:0)});
    }
    que.push((state){s.x,s.y,(s.t+1)%6,s.d+1});
  }
  int res=INF;
  rep(i,6)minch(res,dist[gx+100][gy+100][i]);
  if(res==INF)cout<<-1<<endl;
  else cout<<res<<endl;
  return 0;
}



Measured memory_bytes: 4832
#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<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return vector<decltype(val)>(n, move(val));
}
const ll INF = 1e15;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    if (a%2 && b%2) PRINT("Yes");
    else PRINT("No");
}


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

class Point {
    int x;
    int y;

    Point(int x, int y) {
        this.x = x;
        this.y = y;
    }

    int distance(Point p) {
        return (p.x - this.x)*(p.x - this.x) + (p.y - this.y)*(p.y - this.y);
    }

}

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int n = Integer.parseInt(br.readLine());

        Point[] p = new Point[n];
        String[] line = new String[2];

        for (int i = 0; i < n; i++) {
            line = br.readLine().split(" ");
            p[i] = new Point(Integer.parseInt(line[0]), Integer.parseInt(line[1]));
        }

        // implements compare by inner class 
        Arrays.sort(p, new Comparator<Point>() {
            public int compare(Point p1, Point p2) {
                return p1.x - p2.x;
            }
        });

        int result = Integer.MAX_VALUE;

        for (int i = 1; i < n; i++) {
            for (int j = i-1; j >= 0; j--) {
                if (p[i].x - p[j].x >= Math.sqrt(result))
                    break;
                result = Math.min(result, p[i].distance(p[j]));
            }
        }

        System.out.println(result);
    }
}


Measured memory_bytes: 111764
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>

using namespace std;

int main(void) {
  int N;
  cin >> N;
  int h[N];
  for (int i = 0; i < N; i++) {
    cin >> h[i];
  }
  int s = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      s += h[i] * h[j];
    }
  }
  cout << s << endl;
  return 0;
}


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

int main()
{
    char s[200001];
    scanf("%s", s);

    int i = 0;
    int mode = 2;
    long long countA = 0;
    long long countBC = 0;
    long long sum = 0;
    int len = std::strlen(s);
    while(i <= len){
        switch(mode){
            case 0: //A
                if(s[i] == 'A'){
                    countA++;
                    i++;
                }
                else mode = 1;
                break;
            case 1: //BC
                if(i < len - 1 && s[i] == 'B' && s[i+1] == 'C'){
                    countBC++;
                    i += 2;
                }
                else{
                    sum += countA * countBC;
                    countBC = 0;
                    if(s[i] == 'A'){
                        mode = 0;
                    }
                    else{
                        countA = 0;
                        mode = 2;
                    }
                }
                break;
            case 2:
                if(s[i] == 'A') mode = 0;
                else i++;
                break;
        }
    }
    printf("%lld\n", sum);
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#define F first
#define S second
#define show(x) cout<<#x<<" "<<x<<" ";
#define f(i,j,k) for(int i = j;i<=k;i++)
#define fr(i,j,k) for(int i = j;i>=k;i--)
#define ll long long
#define all(A)  A.begin(),A.end()  
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);  
const int MSIZE = 1e2+5;
const int MOD = 1e9+7;

int wts[MSIZE];
int vals[MSIZE];

ll dp[MSIZE][(int)1e5+5];

const ll inf = 1e18+7;

int main(){
    FIO
    int N, W; cin>>N>>W;


    f(i,1,N)  cin>>wts[i]>>vals[i];

    //Bottom Up
    int vmax = N*1e3;
    //Base Case
    f(i,0,N)    dp[i][0] = 0;
    f(i,1,vmax) dp[0][i] = inf;

    f(i,1,N)    f(j,1,vmax) {
        dp[i][j] = min((j>=vals[i])?(wts[i]+dp[i-1][j-vals[i]]):(ll)inf,dp[i-1][j]);
    }

    int ans = 0;
    f(i,1,vmax) {
        if(dp[N][i]<inf) {
            // cout<<i<<" "<<dp[N][i]<<endl;
            if(dp[N][i]<=W) ans = i;
            // else break;
        }
    }
    cout<<ans<<endl;

    return 0;

}
    


Measured memory_bytes: 80128
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#define int long long
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const long double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){int ret=1;do{if(y&1)ret=(ll)ret*x%md;x=(ll)x*x%md;}while(y>>=1);return ret;}
inline int Rand(){return rand()*32768+rand();}
int n;
int a[200005],b[200005],ta[200005],tb[200005];
long double c[200005];
pair<long double,long double>stk[200005];int sz;
long double get_k(pair<long double,long double>p1,pair<long double,long double>p2){
	return (p2.second-p1.second)/(p2.first-p1.first);
}
long double get_sum(pair<long double,long double>p1,pair<long double,long double>p2){
	return 1.0*(p2.second+p1.second)*(p2.first-p1.first+1)/2.0-1.0*p1.second;
}
signed main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>ta[i];
	for(int i=1;i<=n;i++)cin>>tb[i];
	int pos=max_element(ta+1,ta+n+1)-ta,_=0;
	for(int i=pos;i<=n+pos;i++){
		a[++_]=ta[i>n?i-n:i];
		b[_]=tb[i>n?i-n:i];
	}
	n=_;
	for(int i=2;i<n;i++){
		c[i+1]=2.0*c[i]-2.0*b[i]-c[i-1]; 
	}
	stk[++sz]=make_pair(1,a[1]+c[1]);
	for(int i=2;i<=n;i++){
		pair<int,int>p=make_pair(i,a[i]+c[i]);
		while(sz>=2){
			pair<int,int>p1=stk[sz--];
			pair<int,int>p2=stk[sz];
			if(get_k(p1,p)<get_k(p1,p2)){
				sz++;break;
			}
		}
		stk[++sz]=p;
	}
	long double ans=a[1]+c[1];
	for(int i=1;i<sz;i++){
		ans+=get_sum(stk[i],stk[i+1]);
	}
	for(int i=1;i<=n;i++)ans-=c[i];
	ans-=a[n];
	printf("%.15lf\n",(double)ans/(n-1));
	return 0;
}

Measured memory_bytes: 19240
#include <iostream>
#include <string>
using namespace std;
int main(){
  string text;
  getline(cin,text,'\n');
  for(int i=0;i<text.size();i++)
    if('a'<=text[i]&&text[i]<='z')
      text[i]-=32;
  cout <<text<< endl;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main(void){
   // Your code here!
   int a,b,c;
   cin >> a;
   cin >> b;
   cin >> c;
   if(a>=b){
       int temp=a;
       a=b;
       b=temp;
   }
   if(b>=c){
       int temp=b;
       b=c;
       c=temp;
   }
   if(a>=b){
       int temp=a;
       a=b;
       b=temp;
   }
 
   else{
}
   cout << a;
   cout << " ";
   cout << b;
   cout << " ";
   cout << c;
   cout << endl;
} 


Measured memory_bytes: 3088
object Main {
  def main(args: Array[String]): Unit = {
    val in = new java.util.Scanner(System.in)
    val list = getList(in,10)
    val sorted = list.sorted
    val ls = sorted.reverse
    printList(ls, 3)
  }
  def getList(in:java.util.Scanner,size:Int):List[Int] ={
    if(size == 0){
      return Nil
    }
    val height = in.nextInt()
    return height :: getList(in,size-1)
  }
  def printList(list:List[Int],size : Int):Unit ={
    if(size == 0){return}
    list match{
      case l :: ls => println(l) ; printList(ls, size-1)
      case Nil => println("error")
    }
  }
}

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

using namespace std;

#define LL long long int
#define FASTIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

const int oo = 1e9;
// const LL oo = 1e18;
// const int MOD = 1e9 + 7;
const int MOD = 998244353;
const int N = 5e5;
// const long double PI = acos(-1);

int v[N], cnt[N];
void solve() {
    int n, i;
    cin >> n;
    for (i=0;i<n;i++) cin >> v[i];
    if (v[0] != 0) {
        cout << "0\n";
        return;
    }
    if (n == 1) {
        cout << "1\n";
        return;
    }
    sort(v+1, v+n);
    cnt[0] = 1;
    LL ans = 1;
    for (i=1;i<n;i++) {
        if (v[i] == 0) {
            cout << "0\n";
            return;
        }
        cnt[v[i]]++;
        ans = (ans * 1LL * cnt[v[i]-1])%MOD;
    }
    cout << ans << '\n';
    for (i=0;i<=n;i++) cnt[i] = 0;
}

int main() {
     FASTIO; 
    int t = 1; 
    // cin >> t;
    for (int tc = 1; tc <= t; ++tc) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
int main(int argc, char const *argv[]) {
        int N; std::cin >> N;
        int c;
        int ans=0;
        for (int i = 1; i < N+1; i++) {
                if (i%2!=0) {
                        c=0;
                        for (int j = 1; j < i+1; j++) {
                                if (i%j==0) {
                                        c++;
                                }
                        }
                        if (c==8) {
                                ans++;
                        }
                }
        }
        std::cout << ans << '\n';
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define pf(a) printf("%d\n",a)
#define pf2(a) printf("%lld\n",a)
#define Max 100001
using namespace std;

int main()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    int s=0;
    for(int i=0;i<k;i++)
    {
        s+=a[i];
    }
    cout<<s;
}




Measured memory_bytes: 3640
package main

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

var stdin = bufio.NewScanner(os.Stdin)

func main() {
	stdin.Split(bufio.ScanWords)
	var N, M int
	var Ans int

	N = nextInt()
	M = nextInt()

	Ans = (N * (N - 1) / 2) + (M * (M - 1) / 2)

	fmt.Println(Ans)

}

func nextInt() int {
	stdin.Scan()
	i, err := strconv.Atoi(stdin.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextStr() string {
	stdin.Scan()
	i := stdin.Text()
	// if err != nil {
	// 	panic(err)
	// }
	return i
}


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

const int N = 1e2 + 5;
int n, b[N], vis[N], a[N];

bool dfs(int pos, int idx){
    a[idx] = pos;
    if(idx == n)return true;
    
    int used = 0;
    for (int i = 1; i <= n; i++){
        if(vis[i]) used++;
        else if(b[i]+used > i)return false;
    }
    used = 0;
    for (int i = 1; i <= n; i++){
        if(vis[i]) used++;
        else if(b[i]+used == i){
            vis[i] = 1;
            if(dfs(i, idx+1))return true;
            vis[i] = 0;
        }
        
    }
    return false;
}

bool solve(){
    for (int i = 1; i <= n; i++){
        if(b[i] == i){
            vis[i] = 1;
            if(dfs(i, 1))return true;
            vis[i] = 0;
        }
    }
    return false;
}

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n;
    for (int i = 1; i <= n; i++)cin>>b[i];
    
    bool ok = solve();
    if(!ok)cout<<-1<<endl;
    else{
        for (int i = n; i >= 1; i--){
            cout<<b[a[i]]<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
      	
        // 入力
        long a = sc.nextInt();
      	long b = sc.nextInt();
      	long c = sc.nextInt();
      	long d = sc.nextInt();
      	long max=0;

		if((b<0&&c>0)||(a>0&&d<0)){
          max=Math.max(b*c,a*d);
        }else{
          max=Math.max(a*c,b*d);
        }
      System.out.println(max);

    }
}

Measured memory_bytes: 35684
n = int(input())

hs = list(map(int, input().split()))
maxs = [0] * (n + 1)

m = 0
for i in range(n):
    m = max(m, hs[i])
    maxs[i + 1] = m

count = 0
for i in range(n):
    if maxs[i] <= hs[i]:
        count += 1

print(count)

Measured memory_bytes: 3064
A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())-1
print(A[k])

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(std::chrono::system_clock::now().time_since_epoch().count());
const int N = 1e7 + 1,M = 998244353;
int fact[N] = {1},inv[N];
int power(int base,int to){
	int ret = 1;
	while(to){
		if(to&1)ret = ret*1LL*base%M;
		to>>=1;
		base = base*1LL*base%M;
	}
	return ret;
}
void add(int &a,int b){
	a+=b;
	if(a >= M)a-=M;
	if(a < 0)a+=M;
}
int choose(int n,int k){return (fact[n]*1LL*inv[k]%M)*inv[n - k]%M;}
int main(){
	//freopen("input.txt","r",stdin);
	int n;
	cin >> n;
	for(int i = 1;i < N;i++)fact[i] = fact[i - 1]*1LL*i%M;
	inv[N - 1] = power(fact[N - 1],M - 2);
	for(int i = N - 1;i;i--)inv[i - 1] = inv[i]*1LL*i%M;
	int ans = power(3,n);
	for(int i = n/2 + 1;i <= n;i++)
		add(ans,-choose(n,i)*2LL*power(2,n - i)%M);
	printf("%d\n",ans);
}

Measured memory_bytes: 78336
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
namespace doit
{
	inline long long qread()
	{
		long long x=0,p=1;
		char c;
		c=getchar();
		while(c<'0'||c>'9')
		{
			if(c=='-')
				p=-1;
			c=getchar();
		}
		while(c>='0'&&c<='9')
		{
			x=x*10+c-'0';
			c=getchar();
		}
		return x*p;
	}
	inline void put()
	{
		long long high,low,mod,ans1=0,ans2=0;
		low=qread();high=qread();mod=qread();
		if(low%mod==0)
			ans1=low/mod;
		else
			ans1=low/mod+1;
		ans2=high/mod;
		std::cout<<ans2-ans1+1<<"\n";
	}
}
int main()
{
	ios::sync_with_stdio(false);
	doit::put();
}

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

int count_digit(int n)
{
    int count = 0;
    while (n != 0) {
        count++;
        n /= 10;
    }
    return count;
}

int main()
{
      int n, count = 0; cin >> n;
      for (int i=n; i>=1; --i) {
        if (count_digit(i)%2 != 0) {
            count++;
        }
      }
      cout << count << endl;
      return 0;
}


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

int main() {
  
  int N;
  cin>>N;
  string S,T;
  cin>>S>>T;
  string P;
  
  for(int i=0;i<N;i++) {
    P +=S[i];
    P +=T[i];
  }
  cout<<P<<endl;
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define REP(i, n) for(int i = 0; i < n; ++i)

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
	string s; cin >> s;
	int K; cin >> K;
	REP(i, s.length())
	{
		int x = static_cast<int>(s[i] - 'a');
		int dist = (26 - x) % 26;
		if (K >= dist)
		{
			K -= dist;
			s[i] = 'a';
		}
	}
	if (K > 0)
	{
		auto itr = s.rbegin();
		int x = static_cast<int>(*itr - 'a');
		x = (x + K) % 26;
		*itr = static_cast<char>('a' + x);
	}
	cout << s << endl;
}

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

int main(){
  std::vector<int> v;
  v.push_back(2);
  for(int i = 3;v.size()<10001;i+=2){
    bool f = true;
    for(int j=0;v[j]*v[j]<=i;j++){
      if(!(i%v[j]))f=false;
    }
    if(f)v.push_back(i);
  }
  int n;
  while(std::cin>>n){
    if(!n)break;
    int sum=0;
    for(;n;n--){
      sum+=v[n-1];
    }
    std::cout<<sum<<std::endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
// istringstream (str) >> x; untuk convert string ke int
string to_string(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}
int n, m, a[100000], hasil;;
int main(){
	while(cin >> n >> m){
		if(n == 0 && m == 0){
			break;
		}
		for(int i = 1; i <= n; i++){
			cin >> a[i];
		}
		hasil = -9999;
		for(int i = 1; i < n; i++){
			for(int u = i+1; u <= n; u++){
				if(a[i]+a[u] <= m){
					hasil = max(hasil, a[i]+a[u]);
				}
			}
		}
		if(hasil < 0){
			cout << "NONE\n";
		}
		else{
			cout << hasil << endl;
		}
	}
	return 0;
}




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

int main(){
   int a, b, c;
   char poi;
   while(1){
    cin >> a >> b >> c;
    if(a == -1 && b == -1 && c == -1) break;
    int sum = a + b;
    if(sum >= 80) poi = 'A';
    else if(sum >= 65 && sum < 80) poi = 'B';
    else if(sum >= 50 && sum < 65) poi = 'C';
    else if(sum >= 30 && sum < 50){
           poi = 'D';
           if(c >= 50) poi = 'C';
           }
    else if(sum < 30) poi = 'F';
    
    if(a == -1 || b == -1) poi = 'F';
            
    cout << poi << endl;

    }
    
    return 0;

   }

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

class Gao{
private:
    int life;
    int force;
public:
    Gao(int x,int y):life(x),force(y){};
    void battle(int x1){life=life-x1;}
    int getF(){return force;}
    int getL(){return life;}
};

class Qin{
private:
    int life;
    int force;
public:
    Qin(int x,int y):life(x),force(y){};
    void battle(int x1){life=life-x1;}
    int getF(){return force;}
    int getL(){return life;}
};

void myBattle(Gao a,Qin b)
{
    while(1)
    {
        b.battle(a.getF());
        if(b.getL()<=0)
        {
            cout<<"Yes"<<endl;break;
        }
        else{
            a.battle(b.getF());
            if(a.getL() <=0)
            {
                cout<<"No"<<endl;break;
            }
        }
    }
}






int main() {
    int l1,f1,l2,f2;
    cin>>l1>>f1>>l2>>f2;
    Gao a(l1,f1);
    Qin b(l2,f2);
    myBattle(a,b);
    return 0;
}


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

using namespace std;

int32_t main() {

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    long long a;

    cin >> a;

    long long b;

    cin >> b;

    if(500*a<b) {

        cout << "No" <<'\n';

    } else {

        cout << "Yes" <<'\n';

    }

    return 0;

}



Measured memory_bytes: 3544
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 10e9;

int t[100010];
void Derangement() {
	int n;
	cin >> n;
	int count = 0;
	int chain = 0;
	for (size_t i = 1; i <= n; i++)
	{

		cin >> t[i];
		if (t[i] == i) {
			count++;
			chain++;
		}
		else {
			count -= (chain / 2);
			chain = 0;
		}
	}
	cout << (count - (chain / 2)) << endl;
}

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



Measured memory_bytes: 640
#include <stdio.h>
#define MAX 100000

typedef struct{
  char name[11];
  int time;
}process;

int isEmpty();
process dequeue();
void enqueue(process x);

process p[MAX];
int head=0,tail=0;

int main(){
  int i,n,q,t=0;
  process alt;

  // input
  scanf("%d %d",&n,&q);
  for(i=0;i<n;i++){
    scanf("%s %d",alt.name,&alt.time);
    enqueue(alt);
  }
  // processing
  while(head!=tail){
    if(p[head].time>q){
      p[head].time-=q;
      t+=q;
      alt=dequeue();
      enqueue(alt);
    }
    else {
      t+=p[head].time;
      alt=dequeue();
      printf("%s %d\n",alt.name,t);
    }
  }  
  return 0;
}

int isEmpty(){
  if(tail==head)return 1;
  else return 0;
}

process dequeue(){
  process alt;
  alt = p[head];
  if(head+1==MAX)head=0;
  else head++;    
  return alt;  
}

void enqueue(process x){
  p[tail]=x;
  if(tail+1==MAX)tail=0;
  else tail++;
}

Measured memory_bytes: 2160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int D, L;
  cin >> D >> L;
  cout << D / L + D % L << endl;

  return 0;
}


Measured memory_bytes: 3188
function main(arg) {
  const input = arg.trim().split('\n');
  const x = Number(input[0]);
  if (x === 7 || x === 5 || x === 3) {
    console.log('YES');
  } else {
    console.log('NO');
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 29512
#include <iostream>
using namespace std;
int main()
{
	short int n,m;
	cin>>n>>m;
	short int a[n]={0},h1,h2;
	for(int i=0;i<m;i++)
	{
		cin>>h1>>h2;
		a[h1-1]++;
		a[h2-1]++;
	}
	for(int i=0;i<n;i++)cout<<a[i]<<endl;
	return 0;
}

Measured memory_bytes: 256
seq = input()
st = int(seq[:2:])
nd = int(seq[2::])

if(st == 0 and nd == 0):
    print("NA")
elif((st<=12 and st>0) and (nd<=12 and nd>0)):
    print("AMBIGUOUS")
elif(st<=12 and st>0):
    print("MMYY")
elif(nd<=12 and nd>0):
    print("YYMM")
else:
    print("NA")


Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<int> L(n);
    rep(i, n) cin >> L[i];
    sort(L.begin(), L.end()); // 入力を昇順にソート
    int ans = 0;
    rep(b, n)rep(a, b) { // a と b を固定する
        int ab = L[a] + L[b];
        int r = lower_bound(L.begin(), L.end(), ab) - L.begin(); // L の中で ab 以上になる最初の要素
        int l = b + 1;
        // c = [l, r)
        ans += max(0, r-l);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;
long long fac[510000],finv[510000],inv[510000];
void COMinit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2;i<510000;i++){
    fac[i]=fac[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    finv[i]=finv[i-1]*inv[i]%MOD;
  }
}
long long COM(int n,int k){
  if (n<k) return 0;
  if (n<0 || k<0) return 0;
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
long long facdiv(lint n,lint k){
  if (n<k) return 0;
  if (n<0 || k<0) return 0;
  return (fac[n]*finv[k])%MOD;
}

 
int main(void){
  COMinit();
  lint N,K;
  cin >> N >> K;
  lint red=N-K,blue=K;
  for(int i=1;i<=K;i++){
    lint ans;
    ans=(COM(N-K+1,i)*COM(K-1,i-1))%MOD;
    cout << ans << endl;
  }
}

Measured memory_bytes: 12288
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll;

int main()
{
    int n, k;
    cin >> n >> k;
    int h[200002];
    for(int i = 0; i < n; i++) cin >> h[i];
    sort(h, h + n, greater<int>());
    ll ans = 0;
    for(int i = k; i < n; i++) ans += h[i];
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

#define rep(i, n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {

    string s;
    cin>>s;
    int n = s.size();
    vector<int> v(n,0);

    int prer=0;

    rep(i,n-1){
        if(s[i]=='R'&&s[i+1]=='R'){
            prer++;
        }else if(s[i]=='R'&&s[i+1]=='L'){
            prer++;
            int k=prer/2;
            v[i]+=prer-k;
            v[i+1]+=k;
            prer=0;
        }
    }


    if(prer!=0){
        v[n-1]=prer;
    }
    int prel=0;
    for(int i=n-1;i>0;i--){
        if(s[i]=='L'&&s[i-1]=='L'){
            prel++;
        }else if(s[i]=='L'&&s[i-1]=='R'){
            prel++;
            int c=prel/2;
            v[i]+=prel-c;
            v[i-1]+=c;
            prel=0;
        }
    }
    if(prel!=0){
        v[0]=prel;
    }


    rep(i,n){
        cout<<v[i]<<" ";
    }
    cout<<endl;







    return 0;
}


Measured memory_bytes: 1024
a=int(input())
b=int(input())
c=int(input())
x=int(input())

cnt=0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if 500*i+100*j+50*k==x:
        cnt+=1
print(cnt)

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

using Pos = pair<int, int>;
using ll = long long;

template <class T> inline T abs(const T& a) { return (a < 0) ? -a : a; }

int main() {
  int H, W, D;
  cin >> H >> W >> D;
  map<int, Pos> as;
  {
    int a;
    for(int h = 1; h <= H; ++h) {
      for(int w = 1; w <= W; ++w) {
        cin >> a;
        as[a] = Pos(h, w);
      }
    }
  }
  vector<ll> ds(H * W + 1);
  for(int i = 1; i <= D; ++i) {
    auto crnt = i;
    ds[crnt] = 0;
    while(true) {
      auto next = crnt + D;
      if(next > H * W) {
        break;
      }
      auto a1 = as[crnt];
      auto a2 = as[next];
      ds[next] = abs(a2.first - a1.first) + abs(a2.second - a1.second) + ds[crnt];
      crnt = next;
    }
  }
  int Q;
  cin >> Q;
  vector<pair<int, int>> qs(Q);
  for(int i = 0; i < Q; ++i) {
    cin >> qs[i].first >> qs[i].second;
  }

  for(auto q : qs) {
    int start = q.first;
    int end = q.second;
    ll ans = ds[end] - ds[start];
    cout << ans << endl;
  }

  return 0;
}


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

int main(){
  string a="";
  string s,t="";
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='0'){
      a=a+"0";
      }
    if(s.at(i)=='1'){
      a=a+"1";
      }
    if(s.at(i)=='B'){
      if(a.size()!=0){
        for(int j=0;j<a.size()-1;j++){
          t=t+a.at(j);
          }
        a=t;
        t="";
        }
      }
    }
  cout<<a<<endl;
}

Measured memory_bytes: 256
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

N,E = inpl()
Start = 0
Goal = N-1
ans = 0

lines = defaultdict(set)
cost = [[0]*N for i in range(N)]
for i in range(E):
	a,b,c = inpl()
	if c != 0:
		lines[a].add(b)
		cost[a][b] += c

def Ford_Fulkerson(s):	#sからFord-Fulkerson
	global lines
	global cost
	global ans

	queue = deque()		#BFS用のdeque
	queue.append([s,INF])
	ed = [True]*N	#到達済み
	ed[s] = False
	root = [0 for i in range(N)]	#ルート
	root[s] = -1

	#BFS
	while queue:
		s,flow = queue.pop()
		for t in lines[s]:	#s->t
			if ed[t]:
				flow = min(cost[s][t],flow)	#flow = min(直前のflow,line容量)
				root[t] = s
				queue.append([t,flow])
				ed[t] = False
				if t == Goal: #ゴール到達
					ans += flow
					break
		else:
			continue
		break
	else:
		return False

	#ラインの更新
	t = Goal
	s = root[t]
	while s != -1:

		#s->tのコスト減少，ゼロになるなら辺を削除
		cost[s][t] -= flow
		if cost[s][t] == 0:
			lines[s].remove(t)

		#t->s(逆順)のコスト増加，元がゼロなら辺を作成
		if cost[t][s] == 0:
			lines[t].add(s)
		cost[t][s] += flow

		t = s
		s = root[t]
		
	return True

while True:
	if Ford_Fulkerson(Start):
		continue
	else:
		break

print(ans)



Measured memory_bytes: 7544
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}

int fac[2*maxn+4];

int ifac[2*maxn+4];


ll mod_pow(ll a,ll b,ll p){ //(a^b)%p
	ll res=1;
	a%=p;

	while(b>0){
		if(b&1==1) res=((res%p)*(a%p))%p;
		a=(a%p*a%p)%p;
		b>>=1;
	}
	return res;
}

//mod_inv=mod_pow(denominator,MOD-2,MOD);

void pre(){
	fac[0] = 1;
	for(int i=1;i<=2*maxn;i++){
		fac[i] = i * fac[i-1];
		fac[i]%=mod;
	}
	ifac[2*maxn] = mod_pow(fac[2*maxn],mod-2,mod);
	for(int i=2*maxn-1;i>=0;i--){
		ifac[i] = (i+1) * ifac[i+1];
		ifac[i]%=mod;
	}
}

int nCr(int n, int r){
	if(r>n) return 0;
	if(r==n) return 1;
	int ans = fac[n];
	ans%=mod;
	ans = ans * ifac[r];
	ans%=mod;
	ans = ans * ifac[n-r];
	ans%=mod;
	return ans;
}

int32_t main(){
	fastio();
	int n,k;
	cin>>n>>k;
	pre();
	int ans = 0;
	int pre = 0, suff = 0;
	for(int i=1;i<=n+1;i++){	
		pre+=i-1;
		suff+=(n+1-i);
		pre%=mod;
		suff%=mod;
		if(i>=k) ans = (ans + suff-pre+1+mod)%mod;
	}
	cout<<ans;
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)

const int MOD = 1e+9 + 7;

long long solution(int N, vector<vector<int>>& a)
{
    vector<vector<long long>> dp(N+1, vector<long long>(1<<N, 0));
    dp[0][0] = 1;
    for(int i = 0; i < N; ++i){
        for(int j = 0; j < (1<<N); ++j){
            if(__builtin_popcount(j) != i) continue;
            for(int k = 0; k < N; ++k){
                if(!(j & (1<<k)) and a[i][k] == 1){
                    dp[i+1][j+(1<<k)] += dp[i][j];
                    dp[i+1][j+(1<<k)] %= MOD;
                }
            }
        }
    }
    return dp[N][(1<<N)-1];   
}

int main()
{
    int N;
    cin >> N;
    vector<vector<int>> a(N, vector<int>(N));    
    REP(i, N){
        REP(j, N) cin >> a[i][j];
    }
    
    cout << solution(N, a) << endl;

    return 0;
}

Measured memory_bytes: 377216
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
typedef long long ll;
map<int,int> M = {};

void factor(int n) {
	// nを素因数分解するんご
	for (int i = 2; i<=n; i++) {
		while(n%i==0) {
			M[i]++;
			n/=i;
		}
	}
}

void make(int n) {
	// n!までfactor out
	for (int i=2; i<=n; i++) {
		factor(i);
	}
}

int main(){

	int n;
	cin >> n;
	make(n);

	if (n<=9) {
		cout << "0" << endl;
		return 0;
	}

	int ans;
	int cnt2=0,cnt4=0,cnt24=0,cnt14=0,cnt74=0;

	for (auto &p : M) {
		// cout << p.first << " " << p.second << endl;
		if (p.second >= 2) {
			cnt2++;
		}
		if (p.second >= 4) {
			cnt4++;
		}
		if (p.second >= 24) {
			cnt24++;
		}
		if (p.second >= 14) {
			cnt14++;
		}
		if (p.second >= 74) {
			cnt74++;
		}
	}
	ans = (cnt2-2) * cnt4 * (cnt4-1) / 2;
	ans += cnt24 * (cnt2-1);
	ans += cnt14*(cnt4-1);
	ans += cnt74;
	// cout << cnt2 << " " << cnt4 << endl;
	cout << ans << endl;
}



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

void no(){
  cout<<"No"<<endl;
}

int main(){
  int n;
  string s;
  cin >>n>>s;

  if(n%2==1){
    no();
    return 0;
  }

  else {
    bool flag =true;
    for(int i =0;i<n/2;++i){
      char a =s.at(i);
      char b =s.at(n/2+i);
      if(a!=b){
        flag = false;
        break;
      }
    }

    if(flag){
      cout<<"Yes"<<endl;
    }
    else{
      no();
    }
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,x,sum;
bitset<4000005> s;
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
    return x*f;
}
int main(){
	n=read(); s[0]=1;
	for(int i=1;i<=n;++i){
		x=read();
		s=s|(s<<x);
		sum+=x;
	}
	for(int i=(sum+1)/2;i<=sum;++i)
		if(s[i]){
			printf("%d",i);
			return 0;
		}
}

Measured memory_bytes: 2304
#include<iostream>
int R,C,s[10000][10],f[10],N,i,j,n,m;void rec(int k){if(k<R){f[k]=0;rec(k+1);f[k]=1;rec(k+1);}else{for(n=i=0;i<C;i++,n+=m>R-m?m:R-m)for(m=j=0;j<R;j++)m+=s[i][j]^f[j];N=N>n?N:n;}}main(){for(;std::cin>>R>>C,R;rec(0),printf("%d\n",N))for(j=R;j-->0;)for(i=C;i-->0;)std::cin>>s[i][j];}

Measured memory_bytes: 1260
s=str(input())
cnt=0
cntmax=0
for i in range(len(s)):
    if s[i]=='A' or s[i]=='C' or s[i]=='G' or s[i]=='T':
        cnt += 1
        cntmax = max(cntmax, cnt)
    else:
        cnt = 0
print(cntmax)

Measured memory_bytes: 2940
#include<stdio.h>
int main()
{
    long long int a,b;
    scanf("%lld %lld",&a,&b);
    while(a!=b){
        if(a>b){
            a=a-b;
        }
        else
            b=b-a;
    }
    printf("%lld\n",a);
    return 0;
}



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

int main() {
  string S;
  cin >> S;
  if(S.at(0) == S.at(1)){
cout << "Bad" <<endl;}
else if (S.at(1) == S.at(2)){
cout << "Bad" <<endl;}
else if (S.at(2) == S.at(3)){
cout << "Bad" <<endl;}
else{
cout << "Good" <<endl;}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  vector<int>a(n),b(n),c(n);
  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=0;i<n;i++) cin>>b[i];
  for(int i=0;i<n;i++) cin>>c[i];
  vector<pair<int,pair<int,long long> > > p={};
  for(int i=0;i<n;i++){
    pair<int,long long> p1=make_pair(3,0);
    pair<int,long long> p2=make_pair(2,0);
    pair<int,long long> p3=make_pair(1,0);
    p.push_back(make_pair(a[i],p1));
    p.push_back(make_pair(b[i],p2));
    p.push_back(make_pair(c[i],p3));
  }
  long long count=0;
  sort(p.begin(),p.end());
  for(int i=3*n-1;i>=0;i--){
    if(p[i].second.first==1) count++;
    if(p[i].second.first==2) p[i].second.second=count;
  }
  long long sum=0;
  long long cou=0;
  for(int i=3*n-1;i>=0;i--){
    if(p[i].second.first==2) cou+=p[i].second.second;
    if(p[i].second.first==3) sum+=cou;
  }
  cout<<sum<<endl;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

ll bit_count(ll bits) {
    ll cnt = 0;
    for (; bits != 0; bits >>= 1) {
        cnt += bits & 1;
    }
    return cnt;
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> S(M);
    rep(i, M) {
        int k;
        cin >> k;
        rep(_, k) {
            int s;
            cin >> s;
            s--;
            S[i] = S[i] | (1 << s);
        }
    }
    vector<int> p(M);
    rep(i, M) cin >> p[i];


    int ans = 0;
    rep(bit, 1 << N) {
        bool ok = true;
        rep(i, M) {
            if (bit_count(S[i] & bit) % 2 != p[i]) ok = false;
        }
        if (ok) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
import collections
n=int(input())
a=[int(i) for i in input().split()]

c = collections.Counter(a)
suma=sum(a)
q=int(input())
for i in range(q):
    x,y=map(int,input().split())
    print(suma+c[x]*(y-x))
    suma+=c[x]*(y-x)
    c[y]+=c[x]
    c[x]=0

Measured memory_bytes: 94416
#line 2 "cpplib/util/template.hpp"
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx")
#include<bits/stdc++.h>
using namespace std;
struct __INIT__{__INIT__(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}}__INIT__;
typedef long long lint;
#define INF (1LL<<60)
#define IINF (1<<30)
#define EPS (1e-10)
#define endl ('\n')
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
template<typename T>inline void numout(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i<INF/2?i:"INF";f=1;}cout<<endl;}
template<typename T>inline void numout2(T t){for(auto i:t)numout(i);}
template<typename T>inline void output(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}
template<typename T>inline void output2(T t){for(auto i:t)output(i);}
template<typename T>inline void _output(T t){bool f=0;for(lint i=0;i<t.size();i++){cout<<f?"":" "<<t[i];f=1;}cout<<endl;}
template<typename T>inline void _output2(T t){for(lint i=0;i<t.size();i++)output(t[i]);}
#define rep(i,...) for(auto i:range(__VA_ARGS__)) 
#define rrep(i,...) for(auto i:reversed(range(__VA_ARGS__)))
#define repi(i,a,b) for(lint i=lint(a);i<(lint)(b);++i)
#define rrepi(i,a,b) for(lint i=lint(b)-1;i>=lint(a);--i)
#define irep(i) for(lint i=0;;++i)
inline vector<long long> range(long long n){if(n<=0)return vector<long long>();vector<long long>v(n);iota(v.begin(),v.end(),0LL);return v;}
inline vector<long long> range(long long a,long long b){if(b<=a)return vector<long long>();vector<long long>v(b-a);iota(v.begin(),v.end(),a);return v;}
inline vector<long long> range(long long a,long long b,long long c){if((b-a+c-1)/c<=0)return vector<long long>();vector<long long>v((b-a+c-1)/c);for(int i=0;i<(int)v.size();++i)v[i]=i?v[i-1]+c:a;return v;}
template<typename T>inline T reversed(T v){reverse(v.begin(),v.end());return v;}
#define all(n) begin(n),end(n)
template<typename T,typename E>bool chmin(T& s,const E& t){bool res=s>t;s=min<T>(s,t);return res;}
template<typename T,typename E>bool chmax(T& s,const E& t){bool res=s<t;s=max<T>(s,t);return res;}
const vector<lint> dx={1,0,-1,0,1,1,-1,-1};
const vector<lint> dy={0,1,0,-1,1,-1,1,-1};
#define SUM(v) accumulate(all(v),0LL)
template<typename T,typename ...Args>auto make_vector(T x,int arg,Args ...args){if constexpr(sizeof...(args)==0)return vector<T>(arg,x);else return vector(arg,make_vector<T>(x,args...));}
//#include "../graph_tree/graph_template.hpp"
#line 2 "code.cpp"

int main(){
    lint l,n;
    cin>>n>>l;
    double tmp=0;
    rep(i,n)tmp+=l+i;
    lint mn=INF;
    lint ans2=0;
    rep(i,n){
        lint ans=0;
        rep(j,n){
            if(i==j)continue;
            ans+=l+j;
        }
        if(chmin(mn,abs(tmp-ans)))ans2=ans;
    }
    cout<<ans2<<endl;
}


Measured memory_bytes: 3656