akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;

ll mod(ll x){
    ll res=x%MOD;
    return res+(res<0?MOD:0);
}
ll inv(ll x){
    ll b=MOD,u=1,v=0;
    while(b){
        ll t=x/b;
        x-=t*b;swap(x,b);
        u-=t*v;swap(u,v);
    }
    return mod(u);
}
vector<ll> prods(int x){
    vector<ll> res(x+1);
    res[0]=1;
    for(int i=1; i<=x; i++)res[i]=mod(i*res[i-1]);
    return res;
}
vector<ll> pows(ll a,int x){
    vector<ll> res(x+1);
    res[0]=1;
    a=mod(a);
    for(ll i=1; i<=x; i++)res[i]=mod(a*res[i-1]);
    return res;
}
ll power(ll a, ll n){
    ll res=1;
    a=mod(a);
    for(;n>0;n>>=1){
        if(n&1)res=mod(res*a);
        a=mod(a*a);
    }
    return res;
}

vector<ll> p;//p=prods(MAX_n)
ll comb(ll a, ll b){
    if(b<0||b>a)return 0;
    return mod(mod(p[a]*inv(p[b]))*inv(p[a-b]));
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin>>n;
    vector<ll> x(n);rep(i,n)cin>>x[i];
    ll ans = 0;
    
    p = prods(110000);
    ll a = 0;
    for(int i=0; i<n-1; i++){
        ll dx = x[i+1]-x[i];
        a += p[n-1]*inv(i+1);a%=MOD;
        ans = (ans+(a*dx)%MOD)%MOD;

    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1920
import java.util.Scanner;

/**
 *
 * @author lenovo
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int len = str.length();
        String head = str.substring(0, 1);
        String foot = str.substring(len-1, len);
        
        System.out.println(head + Integer.toString(len-2) +  foot);
    }
    
}


Measured memory_bytes: 23124
import itertools
n = int(input())
c = list(map(int,input().split()))
c.sort()
ac = list(itertools.accumulate(c))
check = [1]*n
for i in range(n-1):
    if ac[i]*2<c[i+1]:
        check[i] = -1
    else:
        check[i] = 1
tmp=0
for i in range(n):
    if check[i]==1:
        tmp+=1
    else:
        tmp =0
print(tmp)

Measured memory_bytes: 14428
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; ++i){ cin >> a[i]; }
	vector<vector<int>> next_table(20, vector<int>(n + 1, n));
	for(int s = 0; s < 20; ++s){
		int last = n;
		for(int i = n - 1; i >= 0; --i){
			next_table[s][i] = last;
			if(a[i] & (1 << s)){ last = i; }
		}
	}
	ll answer = 0;
	for(int i = 0; i < n; ++i){
		int tail = n;
		for(int s = 0; s < 20; ++s){
			if(a[i] & (1 << s)){
				tail = min(tail, next_table[s][i]);
			}else{
				tail = min(tail, next_table[s][next_table[s][i]]);
			}
		}
		answer += tail - i;
	}
	cout << answer << endl;
	return 0;
}



Measured memory_bytes: 17536
[A, V] = list(map(int, input().split()))
[B, W] = list(map(int, input().split()))
T = int(input())
if W-V != 0:
    X = abs(B-A)/(V-W)
    if X > T or X <= 0:
        print('NO')
    else:
        print('YES')
else:
    print('NO')

Measured memory_bytes: 61648
use std::fmt::Debug;
use std::io;
use std::io::{Read, Stdin};
use std::str;
use std::str::FromStr;
use std::usize;
use std::cmp;
use std::collections::vec_deque::VecDeque;
use std::i64::MAX;

fn main() {
    let mut sc = Scanner::new();
    let a = sc.parse::<i64>();
    let b = sc.parse::<i64>();
    if a == b {
        print!("{}", 1);
        return;
    }

    let mut r = 0;
    for i in (0..61).rev() {
        if (a & (1 << i)) != (b & (1 << i)) {
            r = i;
            break;
        }
    }

    let c = (1 << r);

    let mut k = 0;
    for i in (0..r).rev() {
        if (b & (1 << i)) != 0 {
            k = i + 1;
            break;
        }
    }

    let d = c + (1 << k);
    let e = 2 * c;
    let f = (a & (c - 1));
    // [f, d), [f+c, e)


    if d >= f + c {
        // [f, e)
        println!("{}", e - f);
    } else {
        println!("{}", d - f + e - (f + c));
    }
}

struct Scanner {
    stdin: Stdin,
    buf: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner {
            stdin: io::stdin(),
            buf: Vec::with_capacity(256),
        }
    }

    fn parse<T: FromStr>(&mut self) -> T
        where <T as FromStr>::Err: Debug
    {
        self.buf.clear();
        let mut it = self.stdin.lock().bytes();
        let mut c = it.next().unwrap().unwrap();
        while c == ' ' as u8 || c == '\n' as u8 {
            c = it.next().unwrap().unwrap();
        }
        while !(c == ' ' as u8 || c == '\n' as u8) {
            self.buf.push(c);
            c = it.next().unwrap().unwrap();
        }
        str::from_utf8(&self.buf).unwrap().parse::<T>().unwrap()
    }
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
    using namespace std;
    int main()
    {
      int n,i,j,k;
      cin>>n;
      int a[n];
      stack<int > s;int mx=INT_MIN;
      for(i=0;i<n;i++)
      {
    cin>>a[i];
        if(a[i]>mx)
          mx=a[i];
        s.push(mx);
      }
      long long sum=0;
      
      for(i=n-1;i>=0;i--)
      {
        sum+=s.top()-a[i];
        s.pop();
      }
      cout<<sum<<endl;}

Measured memory_bytes: 5132
#include <bits/stdc++.h>
 
using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i< (int) n; i++)
#define PI  3.14159265358979323846264338327950
 
int main () {
    vector<vector<int>>masu(3, vector<int>(3));

    rep(i,3){
        rep(j,3){
            cin >> masu[i][j];
        }
    }

    vector<int>x(3);
    vector<int>y(3);

    x[0] =0;
    rep(i,3)y[i] = masu[0][i];
    rep(i,3)x[i] = masu[i][0]-y[0];
    
    bool check = true;

    rep(i,3){
        rep(j,3){
            if(x[i]+y[j] != masu[i][j])check = false;
        }
    }

    if(check)cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

int main(){
  int k,x=0,l=0;
  array<int, 3> ar;
  for(int i=0;i<3;i++)cin >> ar[i];
  cin >> k;
  for(int j=0;j<3;j++){
    if(x<ar[j]){
      x=ar[j];
      l=j;
    }
  }
  for(int j=0;j<k;j++)ar[l] *= 2;
  cout << ar[0]+ar[1]+ar[2] << endl;
}


Measured memory_bytes: 256
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        a: Chars,
        b: Chars,
        c: Chars,
    };
    let ans = a[a.len() - 1] == b[0] && b[b.len() - 1] == c[0];
    println!("{}", if ans { "YES" } else { "NO" });
}


Measured memory_bytes: 2160
#include <stdio.h>

int main(void)
{
        char s[10];

        scanf("%s",s);

        if(s[0]=='S') printf("Cloudy\n");
        else if(s[0]=='C') printf("Rainy\n");
        else if(s[0]=='R') printf("Sunny\n");

        return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    }
    
    private void solv() {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int[] xs = new int[n];
        for (int i = 0; i < n; i++) xs[i] = input.nextInt();
        
        // sort
        int count = 0;
        for (int i = 0; i < xs.length; i++) {
            for (int j = xs.length - 1; j > i; j--) {
                if (xs[j] < xs[j-1]) {
                    int temp = xs[j];
                    xs[j] = xs[j-1];
                    xs[j-1] = temp;
                    count++;
                }
            }
        }
        print(xs);
        System.out.println(count);
    }
    
    private void print(int[] xs) {
        StringBuilder sb = new StringBuilder();
        for (int x : xs) sb.append(x).append(' ');
        System.out.println(sb.toString().trim());
    }
}

Measured memory_bytes: 18160
N = int(input())

s = [input() for _ in range(N)]
u = list(set(s))

M = int(input())
t = [input() for _ in range(M)]

v = []
for i in range(len(u)):
  v.append(s.count(u[i]) - t.count(u[i]))
  
print(max(v) if max(v) >= 0 else 0)

Measured memory_bytes: 3064
n = int(input())
abc = [list(map(int, input().split())) for _ in range(n - 1)]
q, k = map(int, input().split())
xy = [list(map(int, input().split())) for _ in range(q)]

adj = [[] for _ in range(n)]
for a, b, c in abc:
	a -= 1
	b -= 1
	adj[a].append([b, c])
	adj[b].append([a, c])


def dfs(s):
	d = [-1] * n
	d[s] = 0
	stack = [s]

	while stack:
		u = stack.pop()
		for v, c in adj[u]:
			if d[v] == -1:
				d[v] = d[u] + c
				stack.append(v)

	return d


depths = dfs(k-1)

for x, y in xy:
	x -= 1
	y -= 1
	ans = depths[x] + depths[y]
	print(ans)


Measured memory_bytes: 89312
N,M = map(int,input().split())
A = [0]*N
for i in range(M):
    a,b = map(lambda x:int(x)-1,input().split())
    A[a] = abs(1-A[a])
    A[b] = abs(1-A[b])
ans = "YES"
for a in A:
    if a:ans="NO"
print(ans)

Measured memory_bytes: 3828
#include <bits/stdc++.h>
int n;
long long a[100020];
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
	}
	if (a[n] != 2) {
		printf("-1\n");
		return 0;
	} else {
		long long ansmin = 2;
		long long ansmax = 2;
		for (int i = n; i > 0; i--) {
			if (ansmax / a[i] * a[i] < ansmin) {
				printf("-1\n");
				return 0;
			}
			long long tmpmin = (ansmin + a[i] - 1) / a[i] * a[i];
			long long tmpmax = ansmax / a[i] * a[i] + a[i] - 1;
			ansmin = tmpmin;
			ansmax = tmpmax;
		}
		printf("%lld %lld\n", ansmin, ansmax);
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define boost ios_base::sync_with_stdio(false), cin.tie(NULL);

using namespace std;
const int N = 5e3 + 44;
const int X[] = {1,0,-1,0,1,-1,1,-1};
const int Y[] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1e9 + 7;
const long long INF = 1e18;
const int inf = 1e9;

bool u[N][N];

long long dp[N][N];

long long pref[N];

long long a[N];

long long sum (int l, int r) {
	if (l > r) return 0ll;
	return pref[r] - (l ? pref[l - 1] : 0ll);
}

long long solve (int l, int r) {
	if (l > r) return 0ll;
	if (u[l][r]) return dp[l][r];
	u[l][r] = 1;
	dp[l][r] = sum (l, r) - min (solve (l + 1, r), solve (l, r - 1));
	return dp[l][r];
}

int main () {
	boost;
	int n;
	cin >> n;
	for (int i = 0 ; i < n ; ++ i) {
		cin >> a[i];
		pref[i] += a[i];
		pref[i + 1] = pref[i];
	}
	cout << solve (0, n - 1) - (sum (0, n - 1) - solve (0, n - 1));
}

Measured memory_bytes: 135040
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	
	public static class Island implements Comparable<Island>{
		int island;
		int sink;
		
		public Island(int island, int sink) {
			super();
			this.island = island;
			this.sink = sink;
		}

		@Override
		public int compareTo(Island o) {
			return o.sink - this.sink;
		}
	}
	
	public static int prim(boolean[] treed, boolean[] sinked, int[] costs, final int N, int[][] adj){
		int sum = 0;
		
		while(true){
			Arrays.fill(costs, Integer.MAX_VALUE);
			
			for(int from = 0; from < N; from++){
				if(!treed[from]){
					continue;
				}
				
				for(int to = 0; to < N; to++){
					if(from == to){
						continue;
					}else if(treed[to]){
						continue;
					}else if(!sinked[to]){
						continue;
					}
					
					costs[to] = Math.min(costs[to], adj[from][to]);
				}
			}
			
			int min = Integer.MAX_VALUE;
			int min_pos = -1;
			for(int node = 0; node < N; node++){
				if(min > costs[node]){
					min = costs[node];
					min_pos = node;
				}
			}
			
			if(min_pos == -1){
				break;
			}else{
				treed[min_pos] = true;
				sum += min;
			}
		}
		
		for(int i = 0; i < N; i++){
			if(treed[i] != sinked[i]){
				return 0;
			}
		}
		return sum;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			final int N = sc.nextInt();
			final int M = sc.nextInt();
			
			if(N == 0 && M == 0){
				break;
			}
			
			PriorityQueue<Island> queue = new PriorityQueue<Main.Island>();
			for(int i = 0; i < N; i++){
				queue.add(new Island(i, sc.nextInt()));
			}
			
			int[][] adj = new int[N][N];
			for(int i = 0; i < N; i++){
				for(int j = 0; j < N; j++){
					adj[i][j] = Integer.MAX_VALUE;
				}
			}
			
			for(int i = 0; i < M; i++){
				final int a = sc.nextInt() - 1;
				final int b = sc.nextInt() - 1;
				final int c = sc.nextInt();
				
				adj[a][b] = adj[b][a] = c;
			}
			
			int cost = 0;
			boolean[] sinked = new boolean[N];
			boolean[] treed  = new boolean[N];
			int[] costs = new int[N];
			while(!queue.isEmpty()){
				int prev_time = -1;
				boolean first_time = true;
				
				
				while(!queue.isEmpty() && (prev_time == -1 || prev_time == queue.peek().sink)){
					final Island sink = queue.poll();
					sinked[sink.island] = true;
					prev_time = sink.sink;
					
					if(cost == 0 && first_time){
						first_time = false;
						treed[sink.island] = true;
					}
					
				}
				
				final int ret = prim(treed, sinked, costs, N, adj);
				//System.out.println(Arrays.toString(sinked) + " " + Arrays.toString(treed));
				
				if(ret == 0){
					Arrays.fill(treed, false);
					cost = 0;
				}else{
					cost += ret;
				}
			}
			
			System.out.println(cost);
		}
	}

}

Measured memory_bytes: 164660
import java.util.Scanner;
import java.lang.Math;

public class Main {
  public static void draw_one(int i, int j)
  {
    if((i+j)%2==0) System.out.print("#");
    else System.out.print(".");
  }
  public static void draw(int a, int b)
  {
    for(int i = 0; i < a; i++)
    {
      for (int j = 0; j < b; j++) {
        draw_one(i,j);
      }
      System.out.println();
    }
  }
  public static void main(String[] args)
  {
    Scanner scan = new Scanner(System.in);
    while(true)
    {
      int a = scan.nextInt();
      int b = scan.nextInt();
      if(a ==0 && b == 0) break;
      draw(a,b);
      System.out.println();
    }
    scan.close();
  }
}



Measured memory_bytes: 40124
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

public class Main{
	public static void main(String[] args) {
		SC sc = new SC(System.in);
		int stat=0;
		stat+=sc.nextInt()*4;
		stat+=sc.nextInt()*2;
		stat+=sc.nextInt();
		if(stat==6 || stat==1 || stat==7) {
			pl("Open");
		}
		else {
			pl("Close");
		}
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static int root(int a) {

		int ketasu=0;
		int tmp=a;
		while(tmp>0) {
			ketasu++;
			tmp/=10;
		}
		int constant=(ketasu+1)/2;	//よく使うので定数化
		if(ketasu>=1) {
			int[] suuji=new int[constant];
			tmp=a;
			for(int i=0; i<constant; i++) {
				suuji[constant-1-i]=a%100;
				a/=100;
			}
			int ans=0;
			int kai=0;
			int mae=0;
			if(constant<=1) {
				for(int i=10; i>=0; i--) {
					if(suuji[0]>=i*i) {
						return i;
					}
				}
			}
			else {
				for(int i=0; i<constant; i++) {
					mae+=kai*2;
					for(int j=9; j>=0; j--) {
						if((mae*10+j)*j<=suuji[i]) {
							ans=ans*10+j;
							mae*=10;
							kai=j;
							if(i+1<constant) {
								suuji[i+1]+=(suuji[i]-(mae+j)*j)*100;
							}
							break;
						}
					}
				}
			}
			return ans;
		}
		else {
			return 0;
		}
	}
}


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

int main(){
  int n,a;
  int count=0,answer=30;
  cin >> n;
  
  for(int i=0; i<n; i++){
    count = 0;
    cin >> a;
  	while(true){
      if(a % 2 == 1){
        break;
      }else{
		a /= 2;
        count++;
      }
    }
    
    if(count < answer){
      answer = count;
    }
  }
  
  cout << answer << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

const ll INF=1e18;

vector<ll> to[100100];

ll dist[100100];
ll par[100100];

void dfs(ll v,ll d,ll p=-1){
    dist[v]=d;
    par[v]=p;
    for(auto x:to[v]){
        if(x==p) continue;
        dfs(x,d+1,v);
    }
    return ;
}
ll dfs1(ll v,ll p=-1){
    ll res=0;
    for(auto x:to[v]){
        if(x==p) continue;
        res+=dfs1(x,v);
    }
    return res+1;
}

int main(){
    ll n;
    cin >> n;
    rep(i,n-1){
        ll a,b;
        cin >> a >> b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    dfs(0LL,0LL);
    ll cen=dist[n-1]/2+1;
    ll mid=n-1;
    while(dist[mid]>cen){
        mid=par[mid];
    }
    ll snu=dfs1(mid,par[mid]);
    ll fen=n-snu;
    if(fen>snu){
        cout << "Fennec" << endl;
    }
    else{
        cout << "Snuke" << endl;
    }
    return 0;
} 

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin>>s;
  int len=s.length();
  for(int i=0;i<len;i++){
    if(s[i]=='7'){
      cout<<"Yes"<<endl;
      break;
    }else if(i==len-1){
      cout<<"No"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3500
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
ll n,m,a[10001];
int main(){
	ios::sync_with_stdio(0);
	cin>>n>>m;
	ll sum=0;
	rep(i,m){
		cin>>a[i];
		sum+=a[i];
	}
	if(sum>n)
	cout<<-1;
	else
	cout<<n-sum;
	re 0;
}

Measured memory_bytes: 3692
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

class DRecording {
public:
void solve(std::istream& cin, std::ostream& cout) {
    int n, c;
    cin >> n >> c;
    vector<int> S(n), T(n), C(n);
    for (int i = 0; i < n; i++) cin >> S[i] >> T[i] >> C[i];

    vector<vector<int>> imos(31, vector<int>(int(1e5) + 1));

    for (int i = 0; i < n; i++){
        imos[C[i]][S[i]] += 1;
        imos[C[i]][T[i]] -= 1;
    }

    vector<int> imos2(int(1e5) + 1);

    for (int j = 0; j < 31; j++){
        for (int i = 1; i < int(1e5) + 1; i++){
            if (imos[j][i] > 0)
                imos2[i - 1] += imos[j][i];
            if (imos[j][i] < 0)
                imos2[i] += imos[j][i];
        }
    }

    int ans = 0;
    for (int i = 0; i < int(1e5); i++){
        imos2[i + 1] += imos2[i];
        ans = max(ans, imos2[i + 1]);
    }

    cout << ans << endl;


}
};

int main() {
	DRecording solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 13952
// you should probably see at the bottom ..
#include<bits/stdc++.h>

#ifdef LOCAL
#include "prabh.hpp"
#endif

#define int long long
#define pb push_back
#define range(v) v.begin(),v.end()
#define rrange(v) v.rbegin(), v.rend()
#define mod (int)(1e9 + 7)
#define inf (int)(1e15)
#define N (int)(1e6 + 10)
#define ff first
#define ss second

using namespace std;


void solve() {
    int n; cin >> n;
    vector<int> noCnt(N);
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        noCnt[a]++;
    }

    int hasOne = 0, hasAll = 0;
    int got = 0;

    bitset<N> b;
    for (int i = 2; i < N; i++) {
        int cur = 0;
        if (!b[i]) {
            for (int j = i; j < N; j += i) {
                cur += noCnt[j];
                b[j] = true;
            }
        }

        if (cur) {
            got++;
            if (cur == 1) hasOne++;
            if (cur == n) hasAll++;
        }
    }

    if (hasOne == got) cout << "pairwise coprime" << endl;
    else if (!hasAll) cout << "setwise coprime" << endl;
    else cout << "not coprime" << endl;

}

int32_t main() {
    ios_base::sync_with_stdio(false), cin.tie(nullptr), cin.tie(nullptr);
    int t_c = 1;
//    cin >> t_c;
    while (t_c--)
        solve();
}

/*
 * COME ON DUDE .... DONT GET UP UNTIL U GET THE SOLUTION
 * GIVING UP NOT GONNA HELP .. JUST GET YOUR ASS TO WORK ALREADY ..
 * AND FOR FUCKING SAKE ... DONT PANIC !!
*/


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

int main ()
{
  int N;
string S , f, g;
cin >> N;
S.size()==N;
cin >>S ;
if(N%2==0){
f=S.substr(0,(N/2));
g=S.substr((N/2), N);

if(f==g)
cout << "Yes";
else
    cout << "No";

}
else if(N%2 !=0)
    cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, M;
  cin >> A >> B >> M;
  vector<int> a(A);
  for(int i = 0; i < A; i++) cin >> a[i];
  vector<int> b(B);
  for(int i = 0; i < B; i++) cin >> b[i];
  int minA = *min_element(a.begin(), a.end());
  int minB = *min_element(b.begin(), b.end());
  int ans = minA + minB;
  for(int i = 0; i < M; i++){
    int x, y, c;
    cin >> x >> y >> c;
    x--; y--;
    ans = min(ans, a[x]+b[y]-c);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1152
from collections import defaultdict as dd
N = int(input())
dic=dd(int)
for x in range(1,N+1):
    t1 = N-x**2
    if t1 <= 1:
        continue
    for y in range(1,t1+1):
        t2 = N-x**2-y**2
        if t2 <= 0:
            continue
        for z in range(1,t2+1):
            tmp = x**2+y**2+z**2+x*y+y*z+z*x
            if tmp > N:
                break
            else:
                dic[tmp] += 1

for i in range(N):
    print(dic[i+1])


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

using namespace std;
int main(){
	string s;
	int i;
	cin >> s;
	if(s[0]!='A' ){
		cout << "WA" << endl;
		return 0;
	}
	int cnt;
	for(i=1;i<s.size();i++){
		if(s[i]=='C'){
			cnt++;
			if(i==1 || i==s.size()-1){
				cout << "WA" << endl;
				return 0;
			}
		}else if('a'>s[i] || 'z'<s[i] ){
			cout << "WA" << endl;
			return 0;
		}
	}
	if(cnt==1){
		cout << "AC " << endl;
	}else{
		cout <<"WA" << endl;
	}
}
				

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

int i,j,n,m;
int wall[200][3],tx,ty,sx,sy;

int crosscheck(int tx,int ty,int sx,int sy,int wx,int wy,int rr){

	int abx=tx-sx,aby=ty-sy;
	int awx=wx-sx,awy=wy-sy;
	int bwx=wx-tx,bwy=wy-ty;

	int rr2=rr*rr;
	int aw2=awx*awx+awy*awy;
	int bw2=bwx*bwx+bwy*bwy;
	int ab2=abx*abx+aby*aby;

	int tim=abx*awy-aby*awx;
	int abw=abx*awx+aby*awy;

	if(aw2==rr2 || bw2==rr2)fprintf("%d %d %d %d %d %d %d",tx,ty,sx,sy,wx,wy,rr);
	if(aw2<rr2 && bw2<rr2)return 0;
	if(aw2<rr2 || bw2<rr2)return 1;
	if(abw<0)return 0;
	if(abw>ab2)return 0;
	if( tim*tim/ab2 <= (double)rr2)return 1;

	return 0;
}

int main(){
	while(scanf("%d",&n)*n){

		for(i=0;i<n;i++)scanf("%d %d %d",&wall[i][0],&wall[i][1],&wall[i][2]);

		for(scanf("%d",&m);m>0;m--){
			scanf("%d %d %d %d",&tx,&ty,&sx,&sy);
			int sss=0;
			for(i=0;i<n;i++){
				int wx=wall[i][0],wy=wall[i][1],rr=wall[i][2];
				if(crosscheck(tx,ty,sx,sy,wx,wy,rr))break;
			}
			if(i<n)printf("Safe\n"); else printf("Danger\n");
		}
	}
	return 0;
}

Measured memory_bytes: 584
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

template <typename T> void max_self(T& a, T b) {
    a = max(a, b);
}

// dp[n][m]

bool first_row_or_column(pair<int,int> p) {
    return p.first == 0 || p.second == 0;
}

const int INF = 1e9 + 5;

int main() {
    string a, b;
    cin >> a >> b;
    vector<vector<pair<int,pair<int,int>>>> dp(a.length() + 1,
        vector<pair<int,pair<int,int>>>(b.length() + 1, {-INF,{0,0}}));
    dp[0][0] = {0, {0,0}};
    // dp[i][j] - the max total length so far
    for(int i = 0; i < (int) a.length(); ++i) {
        for(int j = 0; j < (int) b.length(); ++j) {
            if(a[i] == b[j]) {
                max_self(dp[i+1][j+1], make_pair(dp[i][j].first + 1, make_pair(i,j)));
            }
            max_self(dp[i+1][j], make_pair(dp[i][j].first, make_pair(i,j)));
            max_self(dp[i][j+1], make_pair(dp[i][j].first, make_pair(i,j)));
        }
    }
    pair<int,pair<int,int>> answer = {0,{0,0}};
    for(int i = 0; i <= (int) a.length(); ++i) {
        for(int j = 0; j <= (int) b.length(); ++j) {
            max_self(answer, make_pair(dp[i][j].first, make_pair(i, j)));
        }
    }
    string s;
    pair<int,int> cur = answer.second;
    while(!first_row_or_column(cur)) {
        int i = cur.first;
        int j = cur.second;
        pair<int,int> previous = dp[i][j].second; // a cell from which we came to (i,j)
        debug() << imie(cur) imie(previous);
        if(previous == make_pair(i - 1, j - 1)) {
            assert(a[i-1] == b[j-1]);
            s += a[i-1];
        }
        cur = previous;
    }
    //~ debug() << answer;
    reverse(s.begin(), s.end());
    cout << s << endl;
}

Measured memory_bytes: 107392
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main()
{
	string s;
	cin >> s;
	if(s=="SUN")cout<<7<<endl;
	if(s=="MON")cout<<6<<endl;
	if(s=="TUE")cout<<5<<endl;
	if(s=="WED")cout<<4<<endl;
	if(s=="THU")cout<<3<<endl;
	if(s=="FRI")cout<<2<<endl;
	if(s=="SAT")cout<<1<<endl;

	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;(i)--)
#define rrep1(i,n) for(int i=((int)(n));i>0;(i)--)
#define sz(c) ((int)(c).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int> > PP;
const int MAX=1e5+10;


int N, K, S;
int A[500];
void input(){
  cin>>N>>K;
  rep(i,N){
    cin>>A[i];
    S+=A[i];
  }
}

vi sd;
int ans;
void solve(){
  rep1(d,sqrt(S)){
    if(S%d==0){
      sd.pb(d);
      sd.pb(S/d);
    }
  }
  sort(all(sd), greater<int>());

  rep(i,sz(sd)){
    int d=sd[i];
    int tmp=0;
    int df[500];
    int ds=0;
    rep(i,N){
      df[i]=A[i]%d;
      ds+=df[i];
    }
    int ct=ds/d;
    sort(df, df+N, greater<int>());
    tmp=ds;
    rep(i,ct){
      tmp-=df[i];
    }
    if(tmp<=K){
      ans=d;
      break;
    }
  }
}

void output(){
  cout<<ans<<endl;
}

int main(){
  input();
  solve();
  output();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
 
using namespace std;

signed main()
{
    fast;
    int n;
    cin>>n;

    if ( n % 2 == 0 )
    {
        cout<<n/2<<endl;
    }
    else
    {
        cout<<(n/2)+1<<endl;
    }
    return 0;
}

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

int main(){ 
  int a, b;
  cin >> a >> b;
  cout << a * b << endl;
  return 0;
} 

Measured memory_bytes: 3624
#include <iostream>
#include <fstream>
#include <cstdio>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <string.h>
#include <string>
#include <math.h>
#include <iomanip>
using namespace std;

#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define pb push_back

typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

const int mod = 1e9 + 7;
const int mod2 = 998244353;

void fact_init(int n);
ll exp(ll taban, ll us, ll md);
ll ebob(ll a, ll b);
ll ekok(ll a, ll b);
ll komb(ll a, ll b);

vector<ll> fact;
vector<ll> inv_fact;
void fact_init(int n){
    fact.resize(n+5);
    inv_fact.resize(n+5);
    fact[0] = inv_fact[0] = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = (fact[i-1] * i) % mod;
        inv_fact[i] = exp(fact[i], mod-2, mod);
    }
}
ll exp(ll taban, ll us, ll md) {
    ll carpan = taban % md;
    if(carpan == 0) return 0;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % md;
        temp /= 2;
        carpan = (carpan*carpan) % md;
    }
    return res;
}
 
ll ebob(ll a, ll b){
    if(!a)return b;
    return ebob(b%a, a);
}

ll ekok(ll a, ll b){
    return (a*b)/ebob(a, b);
}

ll komb(ll a, ll b){
    if(a < b) return 0;
    return fact[a] * (inv_fact[a-b] * inv_fact[b] % mod) % mod;
}

const int N = 1e5 + 5;

int main(){
    ios::sync_with_stdio(false); cin.tie(NULL);
	int n; cin>>n;
	ll sum = 0;
	vector<int> vec(n);
	for(auto &x: vec) cin>>x;
	int mx = vec[0];
	for(int i = 1; i < n; i++){
		sum += max(0, mx - vec[i]);
		mx = max(mx, vec[i]);
	}
	cout<<sum;
}

Measured memory_bytes: 3988
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>

const int sosu[]={
	2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97
};
#define SOSU_NUM (sizeof(sosu)/sizeof(int))

int func(int x,int *list_p)
{
	int i;
	int wk;
	for(wk=x,i=SOSU_NUM-1 ; i>=0 ; i--) {
		if (sosu[i] > wk) {
			continue;
		}

		if ((wk % sosu[i])==0) {
			list_p[i]++;
			wk /= sosu[i];
			i++;
//			i=SOSU_NUM-1; 
		}
	}
	return 0;

}

int main()
{
	int	   x,y;
	int    x_list[SOSU_NUM];
	int    y_list[SOSU_NUM];
	int    i;
	int    mod;
	int    k,cnt;
	char   inp[128];
	memset(x_list,'\0',sizeof(x_list));
	memset(y_list,'\0',sizeof(y_list));
	while(1) {
		gets(inp);
		sscanf(inp,"%d %d",&x,&y);
		/*--- CALC ---*/
		func(x,x_list);
		func(y,y_list);
		for(mod=1,i=SOSU_NUM-1 ; i>=0 ; i--) {
			if ((x_list[i]!=0)&&(y_list[i]!=0)) {
				if (x_list[i] > y_list[i]) {
					cnt = y_list[i];
				}
				else {
					cnt = x_list[i];
				}

				for (k=0;k<cnt;k++) {
					mod *= sosu[i];
				}
			}
		}
		break;
	}
	printf("%d\n",mod);
	return 0;
}

Measured memory_bytes: 596
# まだ解いてない配点を nokori として持つ
def dfs(i, sum, count, nokori):
    global ans
    if i == d:
        # G 点に満たなければ nokori のうち一番大きいものを解く
        if sum < g:
            use = max(nokori)
            # 解く問題が問題数を超えないように注意
            n = min(pc[use - 1][0], -(-(g - sum) // (use * 100)))
            count += n
            sum += n * use * 100

        if sum >= g:
            ans = min(ans, count)
    else:
        # 総合スコア、解いた問題数、まだ解いてない問題を更新
        dfs(i + 1, sum, count, nokori)
        dfs(i + 1, sum + pc[i][0] * (i + 1) * 100 + pc[i][1], count + pc[i][0], nokori - {i + 1})


d, g = map(int, input().split())
pc = [list(map(int, input().split())) for i in range(d)]

ans = float("inf")

dfs(0, 0, 0, set(range(1, d + 1)))
print(ans)

Measured memory_bytes: 40688
import java.util.*;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long m = 0;
		long a = 0;
		long r = 0;
		long c = 0;
		long h = 0;
		
		for (int i = 0; i < n; i++) {
			char fc = sc.next().charAt(0);
			switch (fc) {
				case 'M':
					m++;
					break;
				case 'A':
					a++;
					break;
				case 'R':
					r++;
					break;
				case 'C':
					c++;
					break;
				case 'H':
					h++;
					break;
			}
		}
		System.out.println(r*c*h + a*c*h + a*r*h + a*r*c + m*c*h + m*r*h + m*r*c + m*a*h + m*a*c + m*a*r);
	}
}

Measured memory_bytes: 44196
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a>=b&&a>=c){
    cout << b+c << endl;
  }else if(b>=a&&b>=c){
    cout << a+c << endl;
  }else if(c>=a&&c>=b){
    cout << a+b << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>

int main(){
  int N, M;
  scanf("%d",&N);
  scanf("%d",&M);
  std::vector<int > x(M);
  for (int i=0; i<M; i++){
    scanf("%d",&x[i]);
  }
  std::sort(x.begin(), x.end());
  std::vector<std::pair<int, int> > dist(M-1);
  for (int i=0; i<M-1; i++){
    dist[i] = std::make_pair(abs(x[i]-x[i+1]), i);
    //printf("push (%d, %d)\n",abs(x[i]-x[i+1]),i);
  }
  std::sort(dist.begin(), dist.end(), std::greater<std::pair<int, int> >());
  int ans = 0;
  if (N>=M){
    printf("0\n");
  } else {
    std::vector<int > kugire(N-1);
    for (int i=0; i<N-1; i++){
      kugire[i] = dist[i].second;
      //printf("kugire push = %d\n",kugire[i]);
    }
    std::sort(kugire.begin(), kugire.end());
    for (int i=0; i<M-1; i++){
      //printf("x[%d]=%d\n",i,x[i]);
      bool find = std::binary_search(kugire.begin(), kugire.end(), i);
      if (!find){ // not find
        ans += abs(x[i]-x[i+1]);
        //printf("ans += %d\n",x[i]);
      }
    }
    printf("%d\n",ans);
  }
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

int main()
{
	int N, A, B;
	cin >> N >> A >> B;

	int train = N * A;
	int tax = B;

	cout << min(train, tax) << endl;


}






Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int a,b;
  cin>>a>>b;
  cout << (a - 1) * (b - 1) << endl;

  return 0;
}


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

int main() {
    int n, k, l;
    cin >> n >> k >> l;
    int roadcount[n + 1], railcount[n + 1];
    vector<int> road[n + 1], rail[n + 1];
    for (int i = 0, p, q; i < k; i++) {
        cin >> p >> q;
        road[p].emplace_back(q);
        road[q].emplace_back(p);
    }
    for (int i = 0, p, q; i < l; i++) {
        cin >> p >> q;
        rail[p].emplace_back(q);
        rail[q].emplace_back(p);
    }
    vector<bool> visited(n + 1);
    for (int i = 1, count = 0; i <= n; i++) {
        if (!visited[i]) {
            visited[i] = true;
            stack<int> stack;
            stack.emplace(i);
            do {
                auto top = stack.top();
                roadcount[top] = count;
                stack.pop();
                for (int j : road[top]) {
                    if (!visited[j]) {
                        visited[j] = true;
                        stack.emplace(j);
                    }
                }
            } while(!stack.empty());
            count++;
        }
    }
    fill(begin(visited), end(visited), false);
    for (int i = 1, count = 0; i <= n; i++) {
        if (!visited[i]) {
            visited[i] = true;
            stack<int> stack;
            stack.emplace(i);
            do {
                auto top = stack.top();
                railcount[top] = count;
                stack.pop();
                for (int j : rail[top]) {
                    if (!visited[j]) {
                        visited[j] = true;
                        stack.emplace(j);
                    }
                }
            } while(!stack.empty());
            count++;
        }
    }
    map<pair<int, int>, int> count;
    for (int i = 1; i <= n; i++) {
        count[{roadcount[i], railcount[i]}]++;
    }
    for (int i = 1; i <= n; i++) {
        cout << count[{roadcount[i], railcount[i]}] << ' ';
    }
    return 0;
}

Measured memory_bytes: 27816
fun main(args : Array<String>) {
    val (N, M)= readLine()!!.split(" ").map { it.toInt() }
    val query = mutableListOf<Pair<Int, Int>>()
    (1..M).forEach {
        val (a, b) = readLine()!!.split(" ").map { it.toInt() }
        query.add(Pair(a -1, b -1))
    }


    var count = 0
    // O(M^2 Ack)
    (0..(M-1)).forEach { i ->
        val queryExceptIthNode = (0..(M-1)).filter { it != i }.map { query[it] }
        val unionFind = UnionFind(N)

        queryExceptIthNode.forEach { pair ->
            val a = pair.first
            val b = pair.second
            unionFind.merge(a, b)
        }

        if (unionFind.size(0) != N) {
            count++
        }
    }

    println(count)
}

class UnionFind(size: Int) {

    var parent: IntArray
    var height: IntArray
    var size: IntArray

    init {
        this.parent = IntArray(size)
        this.height = IntArray(size)
        this.size = IntArray(size)

        for (i in 0 until size) {
            makeSet(i)
        }
    }

    fun merge(x: Int, y: Int) {

        val rootX = root(x)
        val rootY = root(y)

        if (rootX == rootY) {
            return
        }

        if (height[rootX] > height[rootY]) {
            parent[rootY] = rootX
            size[rootX] += size[rootY]

        } else if (height[rootX] < height[rootY]) {
            parent[rootX] = rootY
            size[rootY] += size[rootX]

        } else {
            parent[rootY] = rootX
            size[rootX] += size[rootY]
            height[rootX]++
        }
    }

    fun isSame(x: Int, y: Int) : Boolean {
        return root(x) == root(y)
    }

    fun size(x: Int): Int {
        val rootX = root(x)
        return size[rootX]
    }

    private fun root(x: Int): Int {
        if (x != parent[x]) {
            parent[x] = root(parent[x])
        }
        return parent[x]
    }


    private fun makeSet(i: Int) {
        parent[i] = i
        height[i] = 0
        size[i] = 1
    }
}



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

#define int long long
#define flash ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
		
signed main()
{
    flash
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		int maxx = max({b*d,a*c,a*d,b*c});
		cout<<maxx;		
    }
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

int main()
{
    int N;
    std::cin >> N;
    int SN=0;
    int origin=N;
    for(int i=0; i<10; i++){
        SN+=N%10;
        N=N/10;
    }
    if(origin%SN==0){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
//--- pA ---//
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}
class Solution {
	Reader reader;
	PrintWriter out;
	public Solution() {
		reader = new Reader();
		out = new PrintWriter(System.out);
		while (reader.hasNext()) {
			run_case();
		}
		out.flush();
	}

	private void run_case() {
		int r = reader.ni();
		double res = Math.PI * 2 * r;
		out.println(res);
		return;
	}
}


class Reader {
	BufferedReader br;
	StringTokenizer st;
	public Reader(){
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public String next() {
		if (st.hasMoreTokens()) return st.nextToken();
		try {
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return st.nextToken();
	}
	public boolean hasNext() {
		try {
			if (!st.hasMoreTokens() && !br.ready()) return false;
			else return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
	public int ni() {return Integer.parseInt(this.next());}
	public long nl() {return Long.parseLong(this.next());}
	public String ns() {return this.next();}
}


Measured memory_bytes: 33336
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define fore(i,a,b) for(int i=a,thxicesi=b; i<thxicesi;i++)
#define FIN ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0)
#define sz(s) int(s.size())
using namespace std;

int main()
{FIN;
    int n,m; cin>>n>>m;
    vector<int> heights(n+1);
    fore(i,1,n+1){
        cin>>heights[i];
    }
    vector<int> neighs(n+1);
    fore(i,0,m){
        int a,b; cin>>a>>b;
        neighs[a] = max(neighs[a],heights[b]);
        neighs[b] = max(neighs[b], heights[a]);
    }
    int cnt = 0;
    fore(i,1,n+1){
        if(neighs[i]< heights[i]){
            cnt++;
        }
    }
    cout<<cnt<<"\n";
    return 0;

}


Measured memory_bytes: 3992
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int n,m;
    cin >> n >> m;
    int a,b;
    vector<vector<int>> vec(m);
    REP(i,n){
        cin >> a >> b;
        if(a > m) continue;
        a--;
        vec[a].push_back(b);
    }
    priority_queue<int> q;
    ll ans = 0;
    REP(i,m){
        REP(j,vec[i].size()){
            q.push(vec[i][j]);
        }
        if(q.size() > 0){
            ans += q.top();
            q.pop();
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5632
///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define int long long
#define sz(x) (int)x.size()
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	int n, x, j = 1;
	cin >> n >> x;
	if(x == 1 || x == 2 * n - 1){
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	for(int i = 0; i < n - 2; i++){
		if(j == x - 1)
			j += 3;
		cout << j << " ";
		j++;
	}
	cout << x - 1 << " " << x << " " << x + 1 << " ";
	for(int i = 0; i < n - 2; i++){
		if(j == x - 1)
			j += 3;
		cout << j << " ";
		j++;
	}
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> void amax(T &x, T y) { x = max(x, y); }
template <typename T> void amin(T &x, T y) { x = min(x, y); }
template <typename T> T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

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

void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  vi32 a(n);
  rep(i, n) a[i] = s[i] - '1';
  auto f = [&](vi32 a) {
    int n = sz(a);
    int acc = 0;
    rep(i, n) {
      if ((n - 1 & i) == i) {
        acc += a[i] & 1;
        acc %= 2;
      }
    }
    return acc;
  };
  if (f(a)) {
    cout << 1 << endl;
    return;
  }
  bool one = false;
  rep(i, n) one |= a[i] == 1;
  if (one) {
    cout << 0 << endl;
    return;
  }
  rep(i, n) a[i] >>= 1;
  cout << f(a) * 2 << endl;
}


Measured memory_bytes: 9116
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <utility>
#include <string>
#include <cmath>
#include <set>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; ++i)
typedef long long ll;
typedef pair<int,int> pii;
int main(){
    string a;
    cin >> a;
    set<char>b,c;
    for(auto x:a){
        if(x=='S'){
            b.insert(x);
        }
        else if(x=='N'){
            b.insert(x);
        }
        else{
            c.insert(x);
        }
    }
    if(b.size()%2==0&&c.size()%2==0){
        cout <<"Yes"<< endl;
    }else{
        cout <<"No" << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,n;
  int s[200];
  a = 0;
  scanf("%d",&n);
  for(int i=0;i<n;i++){scanf("%d",&s[i]);}
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
    	a += s[i]*s[j];
    }
  }
  printf("%d",a);
}

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

int main() {
  string S,T;
  cin>>S>>T;
  int A=0;
  for(int i=0;i<S.size();i++){
    if(S.at(i)!=T.at(i)){
      A++;
      break;
    }
  }
  if(A==1){
cout<<"No"<<endl;
  }
  else{
cout<<"Yes"<<endl;
  }
}





Measured memory_bytes: 3632