akhauriyash/Code-Regression huggingface dataset:
from math import gcd
n=int(input())
a=list(map(int,input().split()))
a.sort()
lis=[False]*(10**6+1)
ok=True
d=dict()
for num in a:
    if num in d:
        d[num]+=1
    else:
        d[num]=1
for num in range(2,10**6+1):
    if lis[num]:
        continue
    cnt=0
    for i in range(num,10**6+1,num):
        lis[i]=True
        if i in d:
            cnt+=d[i]
    if cnt>=2:
        ok=False
if ok:
    print("pairwise coprime")
else:
    g=a[0]
    for num in a:
        g=gcd(g,num)
    if g==1:
        print("setwise coprime")
    else:
        print("not coprime")

Measured memory_bytes: 238492
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
using mint = Fp<1000000007>;


//二項係数ライブラリ
const int MAX = 3000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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;
}
//前処理COMinit()忘れずに


void solve() {
    int r1, c1, r2, c2; cin >> r1 >> c1 >> r2 >> c2;

    COMinit();

    mint ans = 0;

    for (int i = r1+1; i <= r2+1; i++) {
        ans += COM(i+c2, c2) - COM(i+c1-1, c1-1);
    }

    cout << ans << endl;
}


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

Measured memory_bytes: 73920
s = input()

if s == 'SAT':
    print(1)
elif s == 'FRI':
    print(2)
elif s == 'THU':
    print(3)
elif s == 'WED':
    print(4)
elif s == 'TUE':
    print(5)
elif s == 'MON':
    print(6)
elif s == 'SUN':
    print(7)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define eb emplace_back
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <class T>
void chmin(T &a, T b) { a = min(a, b); }
template <class T>
void chmax(T &a, T b) { a = max(a, b); }
void ok() { cerr << "ok" << endl; }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> c(h);
    for (int i = 0; i < h; i++) {
        cin >> c[i];
    }
    int res = INF;
    for (int i = 0; i < (1 << (h - 1)); i++) {
        vector<int> co(h);
        int s = __builtin_popcount(i);
        bool ff = true;
        for (int j = 0; j < w; j++) {
            bool f = false;
            int id = 0;
            for (int l = 0; l < h; l++) {
                co[id] += (c[l][j] == '1');
                if (co[id] > k) {
                    s++;
                    for (int m = 0; m < h; m++) {
                        co[m] = 0;
                    }
                    f = true;
                    break;
                }
                if ((i >> l) & 1) {
                    id++;
                }
            }
            if (f) {
                id = 0;
                for (int l = 0; l < h; l++) {
                    co[id] += (c[l][j] == '1');
                    if (co[id] > k) {
                        ff = false;
                        break;
                    }
                    if ((i >> l) & 1) {
                        id++;
                    }
                }
            }
        }
        if (ff) {
            chmin(res, s);
        }
    }
    cout << res << '\n';
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();

		long ans = 0;

		while(x >=500) {
		x = x - 500;
		ans += 1000;
		}
		while(x >= 5) {
			x = x - 5;
			ans += 5;
		}

		System.out.println(ans);


		sc.close();

	}

}


Measured memory_bytes: 22740
program main
  implicit none
  integer :: n, i, cur, res = 0
  integer, allocatable :: v(:), c(:)

  read *, n
  allocate (v(n), c(n))
  read *, v
  read *, c
  
  do i = 1, n
    cur = v(i) - c(i)
    if (cur > 0) res = res + cur
  end do

  print '(i0)', res

end program


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

typedef vector<int > vi;
typedef vector< vi > vvi;
typedef pair< int, int > ii;
#define sz(a)  int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define forn(i,n) for(int i=0;i<n;++i)
#define foru(i,n) for(int i=1;i<=n;++i)
#define fortr(i,v) for(auto &i:v)
#define set(n) __builtin_popcount(n)
#define ll long long
#define MOD 1000000007

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

	ll int A[n+1],pen[n+1];
	foru(i,n)
	{
		A[i]=0;
		pen[i]=0;
	}

	ll int index;
	string s;
	forn(i,m)
	{
		cin>>index;
		cin>>s;
		if(s=="AC")
		{
			A[index]=1;
		}
		else
		{
			if(!A[index])
				++pen[index];
		}
	}
	ll int sum=0;
	foru(i,n)
	{
		sum+=A[i];
	}
	cout<<sum<<" ";
	sum=0;
	foru(i,n)
	{
		sum+=(A[i]>0?pen[i]:0);
	}
	cout<<sum<<endl;
}

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

#define DEBUG_MSG_off

int H;
string S;
vector<string> s_list;
vector<int> v_list;

int main() {
  cin >> H >> S;

  if (3200 <= H) {
    cout << S << "\n";
  } else {
    cout << "red\n";
  }

#ifdef DEBUG_MSG
  cerr << H << " " << S << "\n";
#endif
  return 0;
}

Measured memory_bytes: 256
x, y = map(int, input().split())
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]

if a.count(x) & a.count(y) or b.count(x) & b.count(y) or c.count(x) & c.count(y):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
while True:
    h, w = map(int, input().split())
    if h == 0 and w == 0:
        break
    else:
        for i in range(h):
            s = ''
            if i % 2 == 0:
                for j in range(w):
                    if j % 2 == 0:
                        s += '#'
                    else:
                        s += '.'
            else:
                for j in range(w):
                    if j % 2 == 0:
                        s += '.'
                    else:
                        s += '#'
            print(s)
        print()






Measured memory_bytes: 5612
#include <iostream>
using namespace std;
int main(){
  int a,b,c,x,ans;
  cin>>a>>b>>c;
  for(int i=0;i<a;i++){
    cin>>x;
    for(int m=0;m<b;m+=x){
      ans+=1;
    }
  }
  cout<<ans+c<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
bool Pnumber(int x)
{

	for(int i=2;i<=std::sqrt(x);i++){
		if(i/10 != 0){
			if(i%10==1 || i%10==3 || i%10==7 || i%10==9){
				if(x%i == 0){
					return false;
				}
			}
		}else{
			if(x%i == 0){
				return false;
			}
		}
	}
	return true;
}

int main()
{
	int n;
	std::cin >> n;
	int x[n];
	int cou=0;
	for(int i=0;i<=n-1;i++){
		std::cin >> x[i];
	}
	for(int i=0;i<=n-1;i++){
		if(Pnumber(x[i])){
			cou++;
		}
	}
	std::cout << cou << "\n" ;
	return 0;
}


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

int main(){
	char a, b;
	scanf(" %c %c", &a, &b);
	int x, y;
	x = (a == 'H') ? 1 : -1;
	y = (b == 'H') ? 1 : -1;
	if(x * y > 0) printf("H\n");
	else printf("D\n");
}


Measured memory_bytes: 256
N = int(input())
deadlines = []
for i in range(N):
    a, b = map(int, input().split())
    deadlines.append([b, a])
deadlines.sort()

time = 0
for deadline, task_time in deadlines:
    if time + task_time <= deadline:
        time += task_time
    else:
        time = None
        break
print('Yes' if time is not None else 'No')

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

int main()
{
    string o,e;
    cin >> o;
    cin >> e;

    for (int i = 0; i < e.length(); i++)
    {
        cout << o.at(i);
        cout << e.at(i);
    }
    if(o.length()-e.length()==1) cout << o.at(o.length()-1);
    cout << endl;
    return 0;
}

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

int main(){
    int H, W;
    cin >> H >> W;

    string raw="##";
    for (int i=0; i<W; i++){
        raw+="#";
    }
    cout << raw << endl;

    for(int i=0; i<H; i++){
        string a;
        cin >> a;
        cout << "#"+a+"#" << endl;
    }

    cout << raw << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<string>
#include<stdio.h>
using namespace std;
typedef long long ll;
int cmp(const void *a,const void *b)
{
    int *c = (int *)a;
    int *d = (int *)b;
    return *d - *c;
}
ll a[100000][2];
int main()
{
    char s[4],s2[4];
    int i,j;
    while(scanf("%s",s)!=EOF)
    {
        for(i=2,j=0;i>=0;i--,j++)
            s2[j]=s[i];
        s2[j]='\0';
        if(strcmp(s,s2)==0)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 256
/* Coached by Dukkha */
#include <stdio.h>

#define N 1000
#define MD 1000000007

int solve(int n, int p) {
	return n < p ? 0 : n / p + solve(n / p, p);
}

int main() {
	static char composite[N + 1];
	int n, a, b;
	long long p;

	scanf("%d", &n);
	p = 1;
	for (a = 2; a <= n; a++) {
		if (composite[a])
			continue;
		p = p * (solve(n, a) + 1) % MD;
		for (b = a * a; b <= n; b += a)
			composite[b] = 1;
	}
	printf("%lld\n", p);
	return 0;
}


Measured memory_bytes: 128
n,ma,mb= map(int,input().split())
al=[]
bl=[]
cl=[]
for _ in range(n):
    a,b,c= map(int,input().split())
    al.append(a)
    bl.append(b)
    cl.append(c)
suma=sum(al)
MAX=999999999999
gmincost = [MAX]
def dfsMa(id,count,sel):
    if id==n:return
    dfsMa(id+1,count,sel)
    tempsum = al[id]+count
    bsum=costsum=0
    for j in sel+[id]:
        bsum+=bl[j]
        costsum+=cl[j]
    if costsum > gmincost[0]:
        return
    elif tempsum%ma == 0:
        k=tempsum//ma
        if bsum==k*mb:
            gmincost[0] = min(gmincost[0],costsum)
            return
    dfsMa(id+1,count+al[id],sel+[id])
    return
dfsMa(0,0,[])
if gmincost[0]==MAX:print(-1)
else:print(gmincost[0])

Measured memory_bytes: 9256
#include <stdio.h>
#define MAX 10000
#define NIL (-1)

struct Node{
    int parent, left, right;
};

struct Node T[MAX];
int n;

void preorder(int r);
void inorder(int r);
void postorder(int r);

int main(){
    int i, id, r;
    scanf("%d", &n);
    for( i = 0; i < n; i++){
        T[i].parent = NIL;
    }
    for( i = 0; i < n; i++){
        scanf("%d", &id);
        scanf("%d %d", &T[id].left, &T[id].right);
        if(T[id].left != NIL) T[T[id].left].parent = id;
        if(T[id].right != NIL) T[T[id].right].parent = id;
    }
    for(i = 0; i < n; i++){
        if(T[i].parent == NIL) r = i;
    }
    printf("Preorder\n");
    preorder(r);
    printf("\nInorder\n");
    inorder(r);
    printf("\nPostorder\n");
    postorder(r);
    printf("\n");

    return 0;
}

void preorder(int r){
    printf(" %d", r);
    if(T[r].left != NIL ) preorder(T[r].left);
    if(T[r].right != NIL ) preorder(T[r].right);
}

void inorder(int r){
    if(T[r].left != NIL ) inorder(T[r].left);
    printf(" %d", r);
    if(T[r].right != NIL ) inorder(T[r].right);
}
void postorder(int r){
    if(T[r].left != NIL ) postorder(T[r].left);
    if(T[r].right != NIL ) postorder(T[r].right);
    printf(" %d", r);  
}


Measured memory_bytes: 2112
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner x = new Scanner(System.in);
		int room1[][] = new int[3][10];
		int room2[][] = new int[3][10];
		int room3[][] = new int[3][10];
		int room4[][] = new int[3][10];
		int n = x.nextInt();
		for( int a = 0 ; a < 3 ; a++){
			for(int t = 0 ; t <10 ; t++){
				room1[a][t] = 0;
				room2[a][t] = 0;
				room3[a][t] = 0;
				room4[a][t] = 0;
			}
		}
		int b ;
		int f ;
		int r ;
		int v ;
		for( int i = 0 ; i < n ; i++){
			b = x.nextInt();
			f = x.nextInt();
			r = x.nextInt();
			v = x.nextInt();
			if(b == 1){
				room1[f-1][r-1]+= v;
			}else if(b ==2){
				room2[f-1][r-1]+= v;
			}else if( b== 3){
				room3[f-1][r-1]+= v;
			}else{
				room4[f-1][r-1]+= v;
			}
		}
		for(int d = 0 ; d <3 ; d++){
			for( int c = 0 ; c < 10 ; c++){
			System.out.print(" " + room1[d][c]);
			}
			System.out.println();
		}
		System.out.println("####################");
		for(int d = 0 ; d <3 ; d++){
			for( int c = 0 ; c < 10 ; c++){
			System.out.print(" " + room2[d][c]);
			}
			System.out.println();
		}
		System.out.println("####################");
		for(int d = 0 ; d <3 ; d++){
			for( int c = 0 ; c < 10 ; c++){
			System.out.print(" " + room3[d][c]);
			}
			System.out.println();
		}
		System.out.println("####################");
		for(int d = 0 ; d <3 ; d++){
			for( int c = 0 ; c < 10 ; c++){
			System.out.print(" " + room4[d][c]);
			}
			System.out.println();
		}
	}
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using P = pair<ll, ll>;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}
struct edge {
  ll to, cost;
};

int main() {
int n;
  cin >> n;
vector<vector<int>> d(n,vector<int>(2));
for(int i=0;i<n;i++){
cin>> d[i][0] >> d[i][1];
}  
bool flag = false;
  for(int i=0;i<=n-3;i++){
  if(d[i][0]==d[i][1] && d[i+1][0]==d[i+1][1] &&d[i+2][0]==d[i+2][1]){
    flag=true;
    break;
  }
  }
 if(flag==true)cout << "Yes"<< endl; 
  else cout << "No" << endl;
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

struct Dinic {
  struct edge {
    int to, capacity, rev, id, isrev;
    edge(){}
    edge(int to, int capacity, int rev):to(to), capacity(capacity), rev(rev){}
  };

  vector< vector<edge> > graph;
  vector<int> level, iter;
  Dinic(int sz):graph(sz), level(sz), iter(sz){};
  void add_edge(int from, int to, int capacity) {
    graph[from].push_back(edge(to, capacity, (int)graph[to].size()));
    graph[to].push_back(edge(from, 0, (int)graph[from].size()-1));
  }
  void bfs(int source) {
    fill(level.begin(), level.end(), -1);
    queue<int> que;
    level[source] = 0;
    que.push(source);
    while(!que.empty()) {
      int v = que.front(); que.pop();
      for(int i = 0; i < (int)graph[v].size(); i++) {
	edge& e = graph[v][i];
	if(e.capacity > 0 && level[e.to] < 0) {
	  level[e.to] = level[v] + 1;
	  que.push(e.to);
	}
      }
    }
  }
  int dfs(int v, int sink, int f) {
    if(v == sink) return f;
    for(int &i = iter[v]; i < (int)graph[v].size(); i++) {
      edge& e = graph[v][i];
      if(e.capacity > 0 && level[v] < level[e.to]) {
	int d = dfs(e.to, sink, min(f, e.capacity));
	if(d > 0) {
	  e.capacity -= d;
	  graph[e.to][e.rev].capacity += d;
	  return d;
	}
      }
    }
    return 0;
  }
  int max_flow(int source, int sink) {
    int flow = 0;
    while(1) {
      bfs(source);
      if(level[sink] < 0) return flow;
      fill(iter.begin(), iter.end(), 0);
      int f; while((f = dfs(source, sink, inf)) > 0) flow += f;
    }
  }
};

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N, M, s, t;
  cin >> N >> M >> s >> t;
  --s, --t;
  int G[202][202];
  fill(G[0], G[202], inf);
  rep(i, N) G[i][i] = 0;
  vint u(M), v(M), d(M), c(M);
  rep(i, M) {
    cin >> u[i] >> v[i] >> d[i] >> c[i];
    --u[i], --v[i];
    G[u[i]][v[i]] = d[i];
  }
  rep(i, N) rep(j, N) rep(k, N) chmin(G[j][k], G[j][i]+G[i][k]);
  Dinic dinic(N);
  rep(i, M) {
    //cout << G[s][u[i]]+d[i]+G[v[i]][t] <<" "<< G[s][t] << endl;
    if(G[s][u[i]]+d[i]+G[v[i]][t] == G[s][t]) {
      //cout<<i<<endl;
      rep(j, c[i]) dinic.add_edge(u[i], v[i], 1);
    }
  }
  cout << dinic.max_flow(s, t) << endl;

  return 0;
}



Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define pb push_back
using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a;
    cin >> a;
    if (a < 30){
    	cout << "No" ;
	}
	else {
		cout << "Yes" ;
	}
}  




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

using namespace std;

typedef long long ll;

const int MAX_SUM = 1e5;
const ll INF = LLONG_MAX;

int main () {
  ll n, W;
  cin >> n >> W;
  vector <ll> w(n), v(n);
  for (int i = 0; i < n; i++) cin >> w[i] >> v[i];
  vector <ll> dp(MAX_SUM + 1, INF);
  for (int i = 0; i < n; i++) {
    vector <ll> newDP(MAX_SUM + 1, INF);
    newDP[v[i]] = w[i];
    for (int j = 1; j <= MAX_SUM; j++) {
      newDP[j] = min(newDP[j], dp[j]);
      if (dp[j] < INF and j + v[i] <= MAX_SUM) newDP[j + v[i]] = min(newDP[j + v[i]], dp[j] + w[i]);
    }
    dp = newDP;
  }
  ll ans = 0;
  for (int val = 1; val <= MAX_SUM; val++) if (dp[val] <= W) ans = val;
  cout << ans << endl;
  return (0);
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int card[50];
int buffer[50];
int main()
{
	int n,r;
	while(cin>>n>>r,n!=0){
		for(int i=0;i<n;i++)card[i]=n-i;
		for(int i=0;i<r;i++){
			int p,c;
			cin>>p>>c;
			for(int j=0;j<p-1;j++)
				buffer[j]=card[j];
			for(int j=0;j<c;j++)
				card[j]=card[j+p-1];
			for(int j=0;j<p-1;j++)
				card[j+c]=buffer[j];
		}
		cout<<card[0]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
bool bin(int arr[], int x, int length){
	int low = 0;
	int high = length-1;
	while(low < high){
		int mid = (low + high)/2;
		if(arr[mid] == x ){
			return true;
		}
		else if(arr[mid] < x){
			low = mid+1;
		}
		else{
			high = mid;
		}
	}
	if(arr[low] != x)
		return false;
	else{
		return true;
	}
}
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	int x;
	int length;
	cin >> x >> length;
	int arr[length];
	for(int i =0; i < length+1; ++i){
		cin >> arr[i];
	}
	sort(arr, arr + length);
	int i = 0;
	bool found = false;
  if(length ==0){
    cout << x;
    found = true;
  }
	while(!found){
		bool sm{false};
		bool lar{false};
		int sub = x-i;
		int add = x+i;
		if(!bin(arr,sub, length)){
			// cout << x-i;
			found = true;
			sm = true;
		}
		else if(!bin(arr, add, length)){
			// cout << x+i;
			found = true;
			lar = true;
		}
		if(sm && lar){
			if(abs(sub) > abs(add)){
				cout << add;
			}
			else{
				cout << sub;
			}
		}
		else if(sm){
			cout << sub;
		}
		else if(lar){
			cout << add;
		}
		i+=1;
	}

}

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

int main() {
  int h,w,k,black=0,b,ans=0;
  cin >>h>>w>>k;
  char m[h][w];
  rep(i,h){
    rep(j,w){
      cin>>m[i][j];
      if(m[i][j]=='#')black++;
    }
  }
  char copy[h][w];
  rep(i,1<<h){
    rep(j,1<<w){
      memcpy(copy, m, sizeof(m));
      b=black;
      rep(y,h){
        rep(l,w){
          if(i>>y& 1){
            rep(x,sizeof(*copy)/sizeof(**copy)){
              if(copy[y][x]=='#'){
                b--;
              }
              copy[y][x]='1';
            }
          }
          if(j>>l& 1){
            rep(x,sizeof(copy)/sizeof(*copy)){
              if(copy[x][l]=='#'){
                b--;
              }
              copy[x][l]='1';
            }
          }
        }
      }
      if(b==k){
        ans++;
      } 
    }
  }
  cout <<ans<<endl;
}

Measured memory_bytes: 3560
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;
	int w, h;
	boolean map[][][];
	int dp[][][];
	
	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			h = sc.nextInt();
			w = sc.nextInt();
			if( (h|w) == 0 ) break;
			
			map = new boolean[h][w][4];
			dp = new int[h][w][4];
			for(int i=0;i<2*h-1;i++) for(int j=0;j<(i%2==0? w-1:w);j++){
				map[i/2][j][i%2==0? 2:3] = sc.nextInt() == 0;
			}
			
			for(int i=1;i<h;i++) for(int j=0;j<w;j++)
				map[i][j][1] = map[i-1][j][3];
			
			for(int i=0;i<h;i++) for(int j=1;j<w;j++)
				map[i][j][0] = map[i][j-1][2];
			
//			for(boolean[][] a: map) debug(a);
			
			for(int i=0;i<h;i++) for(int j=0;j<w;j++) {
				for(int k=0;k<4;k++) if(map[i][j][k]){
					map[i][j][k] = false;
					dp[i][j][k] = bfs(j, i);
					map[i][j][k] = true;
				}
			}
			
			System.out.println(dijkstra());
		}
	}
	
	int dijkstra() {
		int[][] c = new int[h][w];
		for(int[] a: c) fill(a, INF);
		c[h-1][w-1] = 0;
		
		PriorityQueue<P> que= new PriorityQueue<P>();
		que.add(new P(w-1, h-1, 0));
		
		for(;!que.isEmpty();) {
			P now = que.remove();
//			debug(now.x, now.y, now.c);
			if( (now.x|now.y) == 0 ) return now.c;
			if( now.c != c[now.y][now.x] ) continue;
			for(int i=0;i<4;i++) if(map[now.y][now.x][i]){
				int nx = now.x + dx[i];
				int ny = now.y + dy[i];
				int nc = now.c + 1;
				nc = max(nc, dp[ny][nx][(i+2)%4]);
//				debug(dp[ny][nx][(i+2)%4], c[ny][nx]);
				if(c[ny][nx] <= nc ) continue;
				c[ny][nx] = nc;
				que.add(new P(nx, ny, nc));
			}
		}
		return -1;
	}
	
	int dx[] = {-1,0,1,0};
	int dy[] = {0,-1,0,1};
	
	int bfs(int x, int y) {
		boolean visited[][] = new boolean[h][w];
		LinkedList<P> que = new LinkedList<P>();
		
		que.add(new P(x, y, 0));
		visited[y][x] = true;
		
		for(;!que.isEmpty();) {
			P now = que.removeFirst();
			if( now.x == w-1 && now.y == h-1 ) return now.c;
			for(int i=0;i<4;i++) if(map[now.y][now.x][i] && !visited[now.y+dy[i]][now.x+dx[i]]) {
				que.addLast(new P(now.x + dx[i], now.y+dy[i], now.c+1));
				visited[now.y+dy[i]][now.x+dx[i]] = true;
			}
		}
		
		return INF;
	}
	
	class P implements Comparable<P>{
		int x, y, c;
		P(int x, int y, int c) {
			this.x = x;
			this.y = y;
			this.c = c;
		}
		@Override
		public int compareTo(P o) {
			// TODO 自動生成されたメソッド・スタブ
			return c-o.c;
		}
	}

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

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 13000
/*********************************************/
//
//???????????´??°?????????????????????????°??????????????????????????????????????????°??????
//
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_2_C&lang=jp
/*********************************************/

#include<stdio.h>

#define MIN 1
#define MAX 10000

int main()
{
	int A[3],cpy;
	
	scanf("%d %d %d", &A[0], &A[1], &A[2]);
	
	if((A[0]>=MIN) && (A[0]<=MAX) && (A[1]>=MIN) && (A[1]<=MAX) && (A[2]>=MIN) && (A[2]<=MAX))
	{
		for(int i=0; i<3; i++)
		{
			for(int j=i+1; j<3; j++)
			{
				if(A[i]>A[j])
				{
					cpy=A[i];
					A[i]=A[j];
					A[j]=cpy;
				}
			}
		}
	}
	else
	{
		/* ERROR */
		return -1;
	}
	
	printf("%d %d %d\n", A[0], A[1], A[2]);
	
	return 0;
}

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

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> A(M+1),B(M+1);
    vector<int> open(M+1,0);
    for(int i=1;i<=M;i++){
        cin >> A[i] >> B[i];
        for(int j=0;j<B[i];j++){
            int c;
            cin >> c;
            c--;
            open[i] |= (1<<c);
        }
    }
    int inf = 1e9;
    vector<vector<int>> dp(M+1,vector<int>(1<<N,inf));
    dp[0][0] = 0;
    for(int i=1;i<=M;i++){
        for(int S=0;S<(1<<N);S++){
            dp[i][S] = min(dp[i][S],dp[i-1][S]);
            int T = S|open[i];
            dp[i][T] = min(dp[i][T],dp[i][S]+A[i]);
        }
    }
    cout << (dp[M][(1<<N)-1]!=inf? dp[M][(1<<N)-1]:-1) << endl;
}

Measured memory_bytes: 16384
#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 10;
double sump[maxn], ans;
int main()
{
	int n, k;
	scanf("%d%d", &n, &k);
	for(int i = 1; i <= n; ++i)
	{
		int val;
		scanf("%d", &val);
		sump[i] = sump[i - 1] + (1 + val) / 2.0;
	}
	for(int i = k; i <= n; ++i)
		ans = max(ans, sump[i] - sump[i - k]);
	printf("%.10lf\n", ans);
	return 0;
}

Measured memory_bytes: 1792
#include<algorithm>
#include<cstdio>
using namespace std;

int n, k;
int h[200000];

int main() {
    scanf("%d %d", &n, &k);
    for (int i = 0; i < n; i++) scanf("%d", &h[i]);
    sort(h, h + n);
    long ans = 0;
    for (int i = 0; i < n - k; i++) ans += h[i];
    printf("%ld\n", ans);
    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k, x, y;
	cin >> n >> k >> x >> y;
	int ans = min(k, n) * x;
	n = max(0, n - k);
	ans += y * n;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

int main(){
    int a, b, c;
    std::cin >> a >> b >> c;

    std::cout << a * b / 2 << std::endl;

    return 0;
}

Measured memory_bytes: 3628
S = list(input())

def f(a,c,i):
    if i == len(S)-1:
        return(a + int(S[i]) + c)
    else:
        return(f(a+c+int(S[i]),0,i+1)+f(a,10*(c+int(S[i])),i+1))


print(f(0,0,0))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main( ) {
    //freopen("B.01.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    vi a={111,222,333,444,555,666,777,888,999};
    int n;
    cin >> n;
    rep(i, 0, 9){
        if(n<=a[i]){
            cout << a[i] << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3540
N = int(input())
alist=[]
if N ==1:
    print("Yes")
    print("2")
    print("1 1")
    print("1 1")
    exit()
if N==2:
    print("No")
    #print("2")
    #print("2 1 2")
    #print("2 1 2")
    exit()

for i in range(2000):
    if i*(i+1)/2 > 100000:
        break
    else:
        alist.append(int(i*(i+1)/2) )

#print(alist)

if N in alist:
    print("Yes")
else:
    print("No")
    exit()

tate=alist.index(N)+1
yoko=alist.index(N)
#print(tate,yoko)
s=[]
tmp=[]
cnt=1
for j in range(tate):
    stmp=[]
    ntmp=[]
    for l in range(len(tmp)):
        #print("nowtmp:",tmp)
        stmp.append(tmp[l].pop(0))
        #print("tmp:",stmp)
    for m in range(yoko-len(stmp)):
        stmp.append(cnt)
        ntmp.append(cnt)
        #print("cnt:",stmp)
        cnt=cnt+1
    #print(stmp)
    s.append(stmp)
    #print("append ntmp:",ntmp)
    tmp.append(ntmp)
    tmp2=[x for x in tmp if x ]
    tmp=tmp2

print(len(s))

for j in range(len(s)):
    #print(" ".join( s[j] ))
    #list1= [ str(s[j][i]) for i in range(len(s[j]))]
    print(len(s[j])," ".join(str(i) for i in s[j]))


Measured memory_bytes: 9716
package main

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

const BUFSIZE = 10000000

var rdr = bufio.NewReaderSize(os.Stdin, BUFSIZE)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	a := NextLineInt()

	var ans int64

	for i := 0; i < n-1; i++ {
		if a[i] < 0 {
			a[i] *= -1
			a[i+1] *= -1
		}
		ans = ans + a[i]
	}

	ans += a[n-1]
	if a[n-1] < 0 {
		var minus int64 = 1e9
		var index int
		for i := 0; i < n-1; i++ {
			if minus > Abs(a[i]) {
				minus = Abs(a[i])
				index = i
			}
		}

		var total int64

		for i := 0; i < n; i++ {
			if i == index {
				continue
			}
			total += Abs(a[i])
		}
		ans = Max(ans, total-minus)
	}

	fmt.Println(ans)

}

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

func NextLineInt() []int64 {
	buf := make([]byte, 0, BUFSIZE)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}

		buf = append(buf, l...)

		if !p {
			break
		}
	}
	str := strings.Split(string(buf), " ")
	l := len(str)

	ret := make([]int64, l)

	for i := range str {
		// ret[i], ok = strconv.Atoi(str[i])
		v, ok := strconv.Atoi(str[i])

		if ok == nil {
			ret[i] = int64(v)
		}
	}

	return ret
}

func Bool2Int(b bool) int {
	if b {
		return 1
	} else {
		return 0
	}
}

func Abs(v int64) int64 {
	if v < 0 {
		return -v
	}
	return v
}

func Min(a, b int64) int64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func Max(a, b int64) int64 {
	if a > b {
		return a
	} else {
		return b
	}
}


Measured memory_bytes: 11648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    int d, g;
    cin >> d >> g;
    vector<int> p(d);
    vector<int> c(d);
    for(int i = 0; i < d; i++)
    {
        cin >> p[i] >> c[i];
    }

    int ans = 10000;
    for(int i = 0; i < 1 << d; i++)
    {
        int score = 0;
        int num = 0;
        for(int j = 0; j < d; j++)
        {
            if(i & 1 << j)
            {
                // solve all p[j]
                score += p[j] * (j+1) * 100;
                score += c[j];
                num += p[j];
            }
        }
        if(score >= g)
        {
            ans = min(ans, num);
        }
        else
        {
            for(int j = d-1; j >= 0; j--)
            {
                if(i & 1 << j) continue;
                if(p[j] * 100 * (j+1) + score < g) break;
                int tmp = (g-score) / (j+1) / 100;
                if((g-score)%((j+1)*100) != 0) tmp++;
                num += tmp;
                ans = min(ans, num);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<utility>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<limits>
#include <bitset>      


#define LL long long
#define f first
#define s second
#define pb push_back
#define mp make_pair


using namespace std;

LL dp[100005][5];
int v[100005][5];
int n;
  
    LL solve(int i, int pv){

            if(i > n) return 0;
            if(dp[i][pv] != -1) return dp[i][pv];

            LL ans = 0;

            for(int j = 1; (j <= 3); j++){ 
                  if(j != pv)
                     ans = max(ans, v[i][j]  + solve(i + 1, j));
                }
            
            return (dp[i][pv] = ans);

          }




int main(){
   
    cin >> n;

    memset(dp, -1, sizeof dp);

    for(int i = 1; i <= n; i++)
    for(int j = 1; j <= 3; j++) 
            cin >> v[i][j];
       
    
    cout << solve(1,0);


    return 0;
}


Measured memory_bytes: 13952
n = int(input())
x, y = 1, 1
for _ in range(n):
    t, a = map(int, input().split())
    if x <= t and y <= a:
        x = t
        y = a
    else:
        if x % t == 0:
            i_x = x // t
        else:
            i_x = x // t + 1

        if y % a == 0:
            i_y = y // a
        else:
            i_y = y // a + 1
        bigger = max(i_x, i_y)
        x = bigger*t
        y = bigger*a
print(x+y)

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()

const int MAX = 1e5+10;

int N, K, R, S, P;
string T;

ll dp[MAX][3]; // dp[i][n] : i回目にnを出した時の最大値

inline ii janken(int idx) {
    if (T[idx] == 'r') return make_pair(0, P);
    else if (T[idx] == 's') return make_pair(1, R);
    else return make_pair(2, S);
}

ll sub(ll s) { // sからK置きに
    REP (i, 3) dp[0][i] = 0;
    ll ans = 0;
    for (ll i = s; i < N; i += K) {
        ii j = janken(i);
        dp[i/K+1][j.first] = max(dp[i/K][(j.first+1)%3], dp[i/K][(j.first+2)%3]) + j.second; // 多い方に勝った点数を追加

        dp[i/K+1][(j.first+1)%3] = max(dp[i/K][j.first], dp[i/K][(j.first+2)%3]);
        dp[i/K+1][(j.first+2)%3] = max(dp[i/K][j.first], dp[i/K][(j.first+1)%3]);
        ans = max({dp[i/K+1][0], dp[i/K+1][1], dp[i/K+1][2]});
    }

    return ans;
}

ll solve() {
    ll ans = 0;
    REP (k, K) ans += sub(k);
    return ans;
}

int main() {
    cin >> N >> K >> R >> S >> P >> T;
    cout << solve() << endl;
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	string prev=s.substr(0,1);
	vector<string> arr;
//	cout<<prev<<endl;
	arr.push_back(prev);
	//cout<<arr.size();
	for(size_t i=1;i<s.length();++i){
		if(s.substr(i,1)==prev && i<s.length()){
		 	arr.push_back(s.substr(i,2));
		 	prev=s.substr(i,2);
		 	++i;
		}
		else{ arr.push_back(s.substr(i,1));prev=s.substr(i,1);}
	}
//	for(string x:arr)
//		cout<<x<<" ";
//	cout<<endl;
	if(*(arr.end()-1)==*(arr.end()-2))
	cout<<arr.size()-1;
	else cout<<arr.size();

	return 0; 
}

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

int main(){
	int n,a[100],mi = 1000000000;
	cin >> n;
	for(int i = 0;i < n;i++) cin >> a[i];
	for(int i = -100;i <= 100;i++){
		int sum = 0;
		for(int j = 0;j < n;j++) sum += (i - a[j]) * (i - a[j]);
		mi = min(mi,sum);
	}
	cout << mi << endl;
	return 0;
}

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

int main() {
    int X;
    cin >> X;

    int t, f;
    // xを５００円で割ったときの商ｔ、余りｆ
    //t * 1000 で５００円はおｋ
    //f /5で５うれしい獲得
    int g, a, b;
    // a = t * 1000
    //gはf/5の商
    
    t = X / 500;
    f = X % 500;
    a = t * 1000;
    g = f / 5;
    b = g * 5;

    cout << a + b << endl;
}

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

int main() {
  int N; cin >> N;
  int cnt = 0;
  int ans = 0;
  for ( int i = 105; i <= N; i+=2 ) {
    cnt = 0;
    for ( int j = 1; j <= 199; j++ ) {
      if ( i % j == 0 ) cnt++;
    }
    if ( cnt == 8 ) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define vi vector<int>
#define F(i,n) for(int i=0;i<(int)n;i++)
#define pb push_back
#define print(x) cout << x << endl;
#define print_array(arr) F(i, arr.size()){cout << arr[i] << "-";}cout << endl;
#define print_line F(i, 60){cout << "--";}cout << endl;
const int mod = 1e9+7;
using namespace std;

void pre(){
	
}
void solve(){
	int a, b;
	cin >> a >> b;
	print(a*b)
	
}
int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	pre();
	int test = 1;
	// cin >> test;
	while(test--) {
	    solve();
	}
	return 0;
}

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


namespace atPra96a
{
    class Class1
    {
        static void Main()
        {
            string[] str = Console.ReadLine().Split(null);
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);

            if (a > b) Console.WriteLine(a - 1);
            else Console.WriteLine(a);
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define forn(b) for(int i = 0; i < b; i++)
#define rforn(b) for(int i = b - 1 ;i >= 0; i--)
#define It(m) for(auto it = m.begin(); it != m.end(); it++)
#define N 500500
#define PI 3.14159265358979323846264338327950L
#define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
const ll mod = (ll)1e9 + 7;
    
int main(){
    speed;
    int a, b; cin >> a >> b;
    a -= 2 * b;
    if(a <= 0) {
        cout << 0;
    }   
    else {
        cout << a;
    }
    return 0;
}

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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<int,int> p;

int n,s[200],ans;
int sum = 0;

int main(){
  cin >> n;
  rep(i,0,n){
    cin >> s[i];
    sum += s[i];
  }
  sort(s,s+n);
  if(sum%10==0){
    ans = 0;
    rep(i,0,n){
      if((sum - s[i])%10 != 0){
        ans = sum - s[i];
        break;
      }
    }
  }else ans = sum;
  cout << ans << endl;


}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cmath>
using namespace std;
using std::swap;


int main()
{	
	int A, B;
	cin >> A >> B;
	if (A >= 13)cout << B << "\n";
	else if (12 >= A && A >= 6)cout << B / 2 << "\n";
	else cout << 0 << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n,a[100001],b[100001],i,k;
int main()
{
	cin>>n;
	for(i=1;i<=n;i++)
	{
	cin>>a[i];
    b[a[i]]=i;
	}
	for(i=1;i<=n;i++)
	cout<<b[i]<<' ';
}


Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

static vector<ll> A;
static vector<pair<ll, ll> > kumi, kumi2;

int main(void){
    ll N;
    ll a;
    cin>>N;
    rep(i, N){
        cin>>a;
        A.push_back(a);
    }
    sort(all(A));
    kumi.push_back({A[0], 1});
    ll index=0;
    rep1(i, N-1){
        if(kumi[index].first==A[i]) kumi[index].second++;
        else{
            index++;
            kumi.push_back({A[i], 1});
        }
    }
    rep(i, kumi.size()){
        if(kumi[i].second>=2) kumi2.push_back(kumi[i]);
    }
    if(kumi2.size()<2) cout<<0<<endl;
    else{
       if(kumi2[kumi2.size()-1].second>=4) cout<<kumi2[kumi2.size()-1].first*kumi2[kumi2.size()-1].first<<endl;
        else cout<<kumi2[kumi2.size()-1].first*kumi2[kumi2.size()-2].first<<endl;
    }
    return 0;
}


Measured memory_bytes: 3188
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair

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

using namespace std;

typedef pair<int,int> pii;

int main(){

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

  string s;
  cin >> s;

  REP(i,s.length()){
    if(i == a){
      if(s[i] != '-'){
        cout << "No\n";
        return 0;
      }
    }else{
      if(s[i] < '0' || s[i] > '9'){
        cout << "No\n";
        return 0;
      }
    }
  }

  cout << "Yes\n";
  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);

		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		int d=sc.nextInt();
		if(a+b<c+d){
			System.out.println("Right");
		}else if(a+b==c+d){
			System.out.println("Balanced");
		}else{
			System.out.println("Left");
		}

	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
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;}

// 0 false, 1 true 
// string to int : -48
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

//a^n % mod
long long modpow(long long a, long long n, long long mod){
    long long res = 1;
    while(n > 0){
        if(n & 1){
            res = res * a % mod;
        }
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll n, m;
    cin >> n >> m;

    cout << modpow(n, m , MOD) << endl;

}


Measured memory_bytes: 3104
/*
@title Macro
@category template
*/
#include <bits/stdc++.h>
using namespace std;
#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 all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;

template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

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

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;

const double PI = acos(-1.0);

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";


#line 1 "geometory/template.cpp"


#line 5 "geometory/template.cpp"
/*
@title Geometory/template.cpp
@category Geometory
*/

typedef complex<double> Point;
typedef pair<Point, Point> Segment;
#define EPS (1e-10)
#define EQ(a, b) (abs((a) - (b)) < EPS)

// 内積
double dot(Point a, Point b){
    return (a.real() * b.real() + a.imag() * b.imag());
}
//外積
double cross(const Point &a, const Point &b){
    return (a.real() * b.imag() - a.imag() * b.real());
}

/*
"https://onlinejudge.u-aizu.ac.jp/courses/library/4/CGL/2/CGL_1_A"
直線 l に p から引いた交点を求める
*/
Point projection(const Segment &l, const Point &p){
    double t = dot(p - l.first, l.second - l.first) / norm(l.second - l.first);
    return l.first + t * (l.second - l.first);
}

bool is_intersected_ls(Point a1, Point a2, Point b1, Point b2){
    return (cross(a2-a1, b1-a1)*cross(a2-a1, b2-b1) < EPS) && (cross(b2-b1, a1-b1)*cross(b2-b1, a2-b1) < EPS);
}


#line 4 "test/CGL_1_A.test.cpp"

int main(){
    cout << fixed << setprecision(20);
    int xp1,yp1,xp2,yp2;
    cin >> xp1 >> yp1 >> xp2 >> yp2;
    Point p1(xp1,yp1);
    Point p2(xp2,yp2);
    Segment l = make_pair(p1, p2);
    int q;
    cin >> q;
    rep(_,q){
        int px, py;
        cin >> px >> py;
        Point p(px, py);
        Point ans = projection(l, p);
        cout << ans.real() << " " << ans.imag() << endl;
    }
}


Measured memory_bytes: 3340
N = int(input())
W = list(map(int, input().split()))
WL = [0] * (N + 1)
WR = [0] * (N + 1)
ans = 10 ** 9
for i in range(N):
    WL[i + 1] = WL[i] + W[i]
    WR[i + 1] = WR[i] + W[-i - 1]
for i in range(N):
    ans = min(ans, abs(WL[i] - WR[-i - 1]))
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <stack>
#define MAX 100000
using namespace std;
int n,m;
vector<vector<int> > list(MAX);
int grp[MAX];
int group;

void dfs(int now){
	stack<int> next;
	grp[now]=group;	next.push(now);
	while(!next.empty()){
		now=next.top();	next.pop();
		for(int i=0;i<(int)list[now].size();i++){
			if(grp[list[now][i]]==-1){
				grp[list[now][i]]=group;
				next.push(list[now][i]);
			}
		}
	}
}

int main(){
	cin>>n>>m;
	int s,t;
	for(int i=0;i<m;i++){
		cin>>s>>t;
		list[s].push_back(t);
		list[t].push_back(s);
	}
	for(int i=0;i<n;i++)	grp[i]=-1;
	group=1;
	for(int i=0;i<n;i++){
		if(grp[i]==-1){
			dfs(i);
			group++;
		}
	}
	int q;	cin>>q;
	for(int i=0;i<q;i++){
		cin>>s>>t;
		if(grp[s]==grp[t])	cout<<"yes"<<endl;
		else 	cout<<"no"<<endl;
	}
	return 0;
}

Measured memory_bytes: 7012
a, b, c, d = input().split() 
a = int(a)
b = int(b)
c = int(c)
d = int(d)
xy1 = a*c
xy2 = a*d
xy3 = b*c
xy4 = b*d
 
print(max([xy1, xy2, xy3, xy4]))

Measured memory_bytes: 9120