akhauriyash/Code-Regression huggingface dataset:
// ICPC 2004 à\I B
// Red and Black
// C++ queue Å

#include <cstdio>
#include <queue>

using namespace std;

struct Coord {
  int col;
  int row;
};

int solve (int W, int H);
  
int main () {
  while (1) {
    int W, H;
    scanf("%d%d", &W, &H);
    if (W==0 && H==0) break;
    printf("%d\n", solve(W,H));
  }

  return 0;
}

int solve (int W, int H) {
  char M[H+2][W+2];
  Coord start;
  //  ÇiÔºjÌÝè 
  for (int i=0; i<=W+1; i++) { M[0][i] = '#'; M[H+1][i] = '#'; }
  for (int i=1; i<=H; i++) { M[i][0] = '#'; M[i][W+1] = '#'; }
  //  f[^ÌÇÝÝ
  for (int i=1; i<=H; i++) {
    for (int j=1; j<=W; j++) {
      scanf(" %c", &M[i][j]);
      if (M[i][j]=='@') {
	start.row = i;	start.col = j;
      }
    }
  }


  // X^[gn_ÌÝè
  queue<Coord> Q;                              // BZðÛ·éL[
  Q.push(start);                               // X^[gn_ð enqueue
  int c=1;                                     // BZJE^

  // ÈºTõi±ê©çìéj
	while( !Q.empty()){
		Coord current = Q.front();Q.pop();
		int D1[] ={1,0,-1,0};int D2[]={0,-1,0,1};
		for ( int d=0;d<4;d++){
			Coord nc = current;
			nc.row += D1[d]; nc.col += D2[d];
//		printf("r:%d , c:%d\n",nc.row ,nc.col);
			if (M[ nc.row ][ nc.col ]=='.'){
				M[ nc.row ][ nc.col ]='*';
				Q.push(nc);
				c++;
			}
		}
	}

  return c;
}

Measured memory_bytes: 0
(defun solve (a b c)
  (when (= a b c)
    (if (oddp a)
      (return-from solve 0)
      (return-from solve -1)))
  (labels 
    ((proc (a b c num)
       (if (or (oddp a) (oddp b) (oddp c))
         (return-from proc num) 
         (proc (/ (+ b c) 2) (/ (+ c a) 2) (/ (+ a b) 2) (1+ num)))))
    (proc a b c 0)))
(princ (solve (read) (read) (read)))

Measured memory_bytes: 13028
import java.lang.Long.min
import java.math.BigInteger

private fun getLongs(): LongArray {
    return readLine()!!.split(" ").map {it.toLong()}.toLongArray()
}


private fun absL(l:Long):Long {
    return if (l<0) {-l} else {l}
}

private fun solver(x:Long,k:Long,d:Long):Long{
    if (k % 2 == 0L) {
        return evensolve(x,k,d)
    } else {
        return oddsolve(x,k,d)
    }
}
private fun evensolve(x:Long,k:Long,d:Long):Long {
    val xx = absL(x)
    if (condBigInt(xx,k,d)) {
        return xx - k*d
    }
    // 原点を通り過ることができる。
    // 実質的に2dグリッドで動ける。
    // 原点を通り過ぎない。
    val a = xx % (2 * d)
    // 通り過ぎる場合。
    val b = (2 * d) - a
    return min(a,b)
}

private fun oddsolve(x:Long,k:Long,d:Long):Long {
    // 最初の動く方向を右左どちらかに固定した場合偶数に帰着。
    return min(evensolve(x+d,k-1,d),evensolve(x-d,k-1,d))
}

fun main(){
    val v = getLongs()
    print(solver(v[0],v[1],v[2]))
}

private fun condBigInt(x:Long,k:Long,d:Long):Boolean {
    return x.toBigInteger() >= k.toBigInteger() * d.toBigInteger()
}

Measured memory_bytes: 36608
# -*- coding:utf-8 -*-

def solve():
    N = int(input())
    As = list(map(int, input().split()))
    dic = {}

    for a in As:
        if not a in dic:
            dic[a] = True
            continue
        print("NO")
        return
    print("YES")


if __name__ == "__main__":
    solve()


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

int main() {
  int N; cin >> N;
  vector<vector<int>> to(N), cost(N);
  vector<int> ans(N, -1); ans[0] = 0;
  queue<int> q;
  for(int i = 1; i < N; ++i) {
    int a, b, w; cin >> a >> b >> w;
    a--; b--;
    to[a].push_back(b);
    cost[a].push_back(w);
    to[b].push_back(a);
    cost[b].push_back(w);
  }
  q.push(0);
  while(!q.empty()) {
    int v = q.front();
    q.pop();
    for(int i = 0; i < to[v].size(); i++) {
      int s = to[v][i];
      int t = cost[v][i];
      if(ans[s] != -1) continue;
      ans[s] = (ans[v] + t) % 2;
      q.push(s);
    }
  }
  for(int i = 0; i < N; ++i) {
    cout << ans[i] << endl;
  }

  return 0;

}


Measured memory_bytes: 11904
// untiioiiiiiiiiiiiiiasaaa
#include<bits/stdc++.h>
using namespace std;
#define X first
#define S second

#define all(v) (v).begin(), (v).end()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,b) FOR(i,0,b)
#define reps FOR
#define eb emplace_back
#define pb eb

using LL = long long;
using pii = pair<int, int>;

int N;
int Q;
LL L, R;
vector<LL> as;
LL cmd[214514][4];

LL Eval(LL v) {
  rep(i, Q) {
    if (cmd[i][0] == 1) {
      if (cmd[i][1] <= v) {
        v = (v+cmd[i][2])*cmd[i][3];
      }
    } else if (cmd[i][0] == 2) {
      if (cmd[i][1] >= v) {
        v = (v-cmd[i][2])/cmd[i][3];
      }
    }
  }
  return v;
}

int main() {
  cin >> N >> Q >> L >> R;
  rep(i, N) {
    LL a;
    cin >> a;
    as.eb(a);
  }
  sort(all(as));

  rep(i, Q) {
    rep(j, 4) {
      cin >> cmd[i][j];
    }
  }

  int ans = 0;
  {
    int low = -1;
    int high = N;
    while (high - low > 1) {
      int mid = (high+low)/2;
      LL res = Eval(as[mid]);
      if (L > res) low = mid;
      else high = mid;
    }
    ans -= low;
  }
  {
    int low = -1;
    int high = N;
    while (high - low > 1) {
      int mid = (high+low)/2;
      LL res = Eval(as[mid]);
      if (R >= res) low = mid;
      else high = mid;
    }
    ans += low;
  }
  cout << ans << endl;
}



Measured memory_bytes: 10712
A=int(input())
B=int(input())
C=int(input())
X=int(input())
ans = 0
for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if 500*i+100*j+50*k==X:
        ans+=1
print(ans)

Measured memory_bytes: 3060
//Bismillahir Rahmanir Rahim
#include <bits/stdc++.h>
using namespace std;

typedef long long              ll;
typedef long double            ld;
typedef pair<int, int>         pi;
typedef vector<int>            vi;
typedef vector<pair<int, int>> vpi;

#define pb       push_back
#define all(x)   begin(x), end(x)
#define sz(x)    (int)(x).size()
#define ff       first
#define ss       second
#define mp       make_pair
#define lb       lower_bound
#define ub       upper_bound
#define tcase()  int t; cin >> t; while(t--)

const int MOD = 1e9 + 7; // 998244353;
const int MX  = 2e5 + 5;
const ll  INF = 1e18;
const ld  PI  = acos((ld) -1);

void setIO(string name = "") {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    if(sz(name)){
        freopen((name+".in").c_str(), "r", stdin);
        freopen((name+".out").c_str(), "w", stdout);
    }
}

int main(){



    int n, k;
    cin >> n >> k;
    double arr[n];

    for(int i = 0; i < n; i++){
        cin >> arr[i];

        arr[i] = (arr[i] + 1) / 2;
    }

    double best = 0, sum = 0;

    for(int i = 0; i < n; i++){
        sum += arr[i];
        if(i >= k) sum -= arr[i - k];
        best = max(best, sum);
    }

    printf("%.12lf", best);
}


Measured memory_bytes: 5348
n=int(input())
dic={}
mxd=[]
mxc=0
for i in range(n):
  s = input()
  if s in dic:
    dic[s] += 1
  else:
    dic[s] = 1
  if dic[s] > mxc:
    mxc=dic[s]
    mxd=[]
  if dic[s] == mxc:
    mxd.append(s)
mxd.sort()
for d in mxd:
  print(d)

Measured memory_bytes: 97112
import math
def main():
    m = (10 ** 9) + 7
    n, a, b = map(int, input().split())

    a_k = math.factorial(a)
    b_k = math.factorial(b)

    # フェルマーの小定理
    a_k = pow(a_k, m - 2, m)
    b_k = pow(b_k, m - 2, m)

    n_a = 1
    for i in range(n-a+1, n+1):
        n_a = (n_a * i) % m

    n_b = 1
    for i in range(n-b+1, n+1):
        n_b = (n_b * i) % m

    n_C_a = a_k * n_a
    n_C_b = b_k * n_b

    n_C_a = n_C_a % m
    n_C_b = n_C_b % m

    p = pow(2, n, m)

    print((p - n_C_a - n_C_b - 1)%m)
    return 0


if __name__ == '__main__':
    main()

Measured memory_bytes: 5804
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    a,b=[parse(BigInt,readline()) for i in 1:2]
    if a<b
        println("LESS")
    elseif a>b
        println("GREATER")
    else
        println("EQUAL")
    end
end
main()

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

using namespace std;

long long n;
long long number[100000001];

bool compare(int a,int b)
{
    return a>b;
}

long long getads(long long input_1,long long input_2)
{
    if(input_1>input_2)
        return input_1-input_2;
    else
        return input_2-input_1;
}

long long getans(long long inputer)
{
    long long answer=0;
    for(int j=1;j<=n;j++)
    {
        answer+=getads(number[j],number[inputer]);
        //printf("abs= %lld\n",getads(number[j],number[inputer]));
        //printf("answer is %lld\n",answer);
    }
    return answer;
}



int main()
{
    scanf("%lld",&n);
    for(int i=1;i<=n;i++)
    {
        long long tmp;
        scanf("%lld",&tmp);
        number[i]=tmp-i;
        //printf("number[%d]is% d\n",i,number[i]);
    }
    sort(number+1,number+n+1,compare);
    if(n%2==0)
    {
        printf("%lld",min(getans(n/2),getans(n/2+1)));

    }

    else
    {
        printf("%lld",getans(n/2+1));

    }
    return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T, class U>using vp = vector<pair<T, U>>;
template<class T>using vv = vector<vector<T>>; template<class T, class U>using vvp = vv<pair<T, U>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MAX = 1e5 + 5, MOD = 1e9 + 7;
constexpr ll LINF = 1ll << 60; constexpr double EPS = 1e-6;
constexpr int dy[4] = { 0,1,0,-1 }, dx[4] = { 1,0,-1,0 };
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int N;
vi A;

int main() {
    cin >> N;
    A.resize(N);
    rep(i, N) cin >> A[i];

    vv<ll> dp = vvec<ll>(N + 1, 4, -LINF);
    dp[0][0] = 0;
    rep(i, 1, N + 1) {
        dp[i][0] = dp[i - 1][0] + A[i - 1];
        chmax(dp[i][0], dp[i - 1][3] + A[i - 1]);

        dp[i][1] = dp[i - 1][0] - A[i - 1];
        chmax(dp[i][1], dp[i - 1][3] - A[i - 1]);

        dp[i][2] = dp[i - 1][2] + A[i - 1];
        chmax(dp[i][2], dp[i - 1][1] + A[i - 1]);

        dp[i][3] = dp[i - 1][2] - A[i - 1];
        chmax(dp[i][3], dp[i - 1][1] - A[i - 1]);
    }

    ll ans = max(dp[N][0], dp[N][3]);
    write(ans);

}

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

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second
const int N = 1e5+5;
int n , a[N] , seg[4*N];
set<int> st;
set<int> ::iterator it;

void update(int node , int st , int en , int idx , int val)
{
    if (st==en)
    {
        seg[node] = val;
    }
    else
    {
        int mid = (st+en)/2;
        if (st <= idx && idx <= mid) update(2*node , st , mid , idx , val);
        else update(2*node+1 , mid+1 , en , idx , val);
        seg[node] = max(seg[2*node] , seg[2*node+1]);
    }
}

int query(int node , int st , int en , int l , int r)
{
    if (r<st || l>en) return -1e9;

    if (l<=st && en <= r)
        return seg[node];

    int mid = (st+en)/2;
    return max(query(2*node , st , mid , l , r) , query(2*node+1 , mid+1 , en , l , r));
}

int BS(int idx)
{
    int l=idx+1 , h=n , mid , ans=1e9;
    while(l<=h)
    {
        mid = (l+h)/2;
        if (query(1,1,n,idx+1,mid) > a[idx])
        {
            ans = min(ans , mid);
            h = mid-1;
        }
        else l=mid+1;
    }
    if (ans == 1e9) return -1;
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin >> n;
    for(int i=1; i<=n; i++)
    {
        cin >> a[i];
        update(1,1,n,i,a[i]);
        st.insert(i);
    }

    int ans=0;
    while(st.size())
    {
        ans++;
        int idx = *st.begin();
        while(idx != -1)
        {
            update(1,1,n,idx,(int)-1000000000);
            st.erase(idx);
            idx = BS(idx);
        }
    }

    cout << ans << '\n';
//
    return 0;
}

Measured memory_bytes: 9716
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a+b+c >= 22)
    cout << "bust" << endl;
  else
    cout << "win" << endl;
}


Measured memory_bytes: 256
import math

a, b = map(int, input().split())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

divisors_a = set(make_divisors(a))
divisors_b = set(make_divisors(b))

common_divisors = []
for a in divisors_a:
    if a in divisors_b:
        common_divisors.append(a)

counter = 0
for i in common_divisors:
    if is_prime(i) or i == 1:
        counter += 1
print(counter)

Measured memory_bytes: 4700
#include <stdio.h>
void swap(int *i, int *j)
{
    int tmp;
    tmp = *i;
    *i = *j;
    *j = tmp;
}
int main(){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a>b)
        swap(&a, &b);
    if(b>c)
        swap(&b, &c);
    if(a>b)
        swap(&a, &b);
    printf("%d %d %d\n",a,b,c);
    return 0;
        
}

Measured memory_bytes: 1776
# -*- coding: utf-8 -*-
def main():
    cards = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1]
    A, B = map(int, input().split())
    if cards.index(A) > cards.index(B):
        print('Alice')
    elif cards.index(A) < cards.index(B):
        print('Bob')
    else:
        print('Draw')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>

int main(void)
{
	double d;
	double v;
	double y;
	double t;
	int n;
	
	while (scanf("%lf", &d) != EOF){
		t = d / 9.8;
		y = 4.9 * pow(t, 2);
		
		n = 1;
		while (y >= 5 * n - 5){
			n++;
		}
		
		printf("%d\n", n);
	}
	
	return (0);
}

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

int main() {
	string s;
	cin >> s;
	if (s[0] != 'A') {
		cout << "WA" << endl;
		return 0;
	}
	int c = 0, keep;
	for (int i = 2; i < s.size() - 1; i++)
		if (s[i] == 'C') {
			c++;
			keep = i;
		}
	if (c != 1) {
		cout << "WA" << endl;
		return 0;
	}
	for (int i = 1; i < s.size(); i++) {
		if (i == keep)
			continue;
		if (s[i]<'a' || s[i]>'z') {
			cout << "WA" << endl;
			return 0;
		}
	}
	cout << "AC" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int k = scan.nextInt();
        int a = scan.nextInt();
        int b = scan.nextInt();
        String ans = "NG";
        outloop:for (int i = 1 ; i*k<=b ; i++){
            if ( (i*k>=a)&&(i*k<=b)){
                ans = "OK";
                break outloop;
            }
        }
        System.out.println(ans);
        }
        }

Measured memory_bytes: 35748
# Aizu Problem 0048: Class
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")

CLASSES = [[48, "light fly"], [51, "fly"], [54, "bantam"], [57, "feather"],
           [60, "light"], [64, "light welter"], [69, "welter"],
           [75, "light middle"], [81, "middle"], [91, "light heavy"],
           [1000, "heavy"]]

for line in sys.stdin:
    w = float(line)
    for weight, name in CLASSES:
        if w <= weight:
            print(name)
            break

Measured memory_bytes: 7436
import java.util.Scanner;
     
    public class Main {
     
    	public static void main(String[] args) {
    		Scanner sc = new Scanner(System.in);
    		String string = sc.nextLine();
    		boolean b = string.contains("a") && string.contains("b") && string.contains("c");
    		System.out.println(b ? "Yes" : "No");
    	}
     
    }

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define INF 1145141919
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int ny, nx;
typedef long long int ll;
using namespace std;

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

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 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;
}

////////////////////////////////////////////////////////////////////
int main()
{

    int N,K; cin >> N >> K;
    vector<int> h(N);
    REP(i,N) cin >> h[i];

    ll dp[100100];
    for(int i=0; i<100100; ++i) dp[i]=INF;

    dp[0]=0;

    REP(i,N){
        FOR(j,1,K+1) chmin(dp[i+j], dp[i]+abs(h[i]-h[i+j]));
    }

    cout << dp[N-1] << endl;

    return 0;
}


Measured memory_bytes: 1408
//AUTHOR:: MOHAMMAD FAISAL
// BEGINNING WITH THE NAME OF ALMIGHTY GOD ALLAH
// Atcoder Beginner Problems
#include<bits/stdc++.h>
#include<iostream>
#include<bitset>
#include<string>
#include<algorithm>
#include <cctype>
#include<unordered_map>
#include<map>
#include<set>
#include<vector>
#include<utility>
#include<iterator>
using namespace std;
//string password;
int gcd(int a,int b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
bool isVowel(char c)
{
    return c=='a' || c=='e' || c=='i' || c=='o' || c=='u';
}
bool isPrime(long long n)
{
  if (n == 1)
  {
    return false;
  }
  long long int i = 2;
  while (i*i <= n)
  {
      if (n % i == 0)
      {
          return false;
      }
      i += 1;
  }
  return true;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.flush();
    int n;
    cin >> n;
    
      string s;
      cin >> s;
      string t;
      cin >> t;
    
      for(int i=0;i<(int)s.size();i++)
      {
        cout<<s[i]<<t[i];
      }

    return 0;
}


Measured memory_bytes: 256
#%%
N, M = map(int, input().split())
x = [0] * M
y = [0] * M
for i in range(M):
    x[i], y[i] = map(int, input().split())

check = [[1, 0] for _ in range(N+1)]
check[1] = [1, 1]

for i in range(M):
    if check[x[i]][0] >= 1:
        check[x[i]][0] -= 1
        check[y[i]][0] += 1
    if check[x[i]][1] == 1:
        check[y[i]][1] = 1
    if check[x[i]][0] == 0:
        check[x[i]][1] = 0

ans = 0
for i in range(N+1):
    if check[i][1] == 1:
        ans += 1
print(ans)


Measured memory_bytes: 21108
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

    double ans = 0.0;
    for (int i = 0; i < n; i++) {
        double x;
        string u;
        cin >> x >> u;

        if (u == "JPY") {
            ans += x;
        } else {
            ans += x * 380000.0;
        }
    }

    cout << fixed << setprecision(8) << ans << "\n";
    return 0;
}

Measured memory_bytes: 888
#include <stdio.h>

long long aaa(long long, long long);
long long t[100] = {};

long long aaa(long long x, long long y)
{
	long long r, x1, y1;
	if (x < y)
	{
		x1 = y;
		y1 = x;
	}
	else
	{
		x1 = x;
		y1 = y;
	}
	r = x1 % y1;
	while (r != 0)
	{
		x1 = y1;
		y1 = r;
		r = x1 % y1;
	}
	return y1;
}

int main()
{
	int n;
	long long ans;
	long long g;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%lld", &t[i]);
	}
	ans = t[0];
	for (int i = 0; i < n-1; i++)
	{
		g = aaa(ans, t[i + 1]);
		ans *=t[i + 1] / g;
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
int gcd(int x,int y){
    int a=x,b=y,c=x%y;
    while(c!=0){
        a=b;
        b=c;
        c=a%b;
    }
    return b;
}
int n,a[200000];
signed main(){
    cin>>n;
    rep(i,n)cin>>a[i];
    int sky;
    rep(i,n){
        if(i==0)sky=gcd(a[i],a[i+1]);
        else sky=gcd(sky,a[i]);
    }
    cout<<sky<<endl;
    return 0;
}
    

Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
typedef long long ll;
const int N=1e5+10,mo=1e9+7;
int f[N],nex[N],n;
char s[N];
void move(int &a,int b){a=(a+b)%mo;}
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	nex[n]=nex[n-1]=n+1;
	for (int i=n-2;~i;i--){
		nex[i]=nex[i+1];
		if (s[i+1]==s[i+2])nex[i]=i+2;
	}
	if (nex[0]==n+1){
		cout<<1<<endl;
		return 0;
	}
	f[0]=1;
	for (int i=0;i<n;i++)
		move(f[i+1],f[i]),
		move(f[nex[i]],f[i]);
	int cnt=0,ans=0,tag=0;
	for (int i=n;i>=1;i--){
		move(ans,(cnt%3==0)*f[i]),
		cnt+=(s[i]=='a')-(s[i]=='b');
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1152
#include <iostream>
#include <climits>
#include <algorithm>
#include <vector>
#include <list>
#include <assert.h>
using namespace std;
typedef long long LL;
const int MAXN = 1000 + 10;
int idx[2], nums[MAXN];
LL sum[2];
int main() {
//    freopen("test.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n; cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> nums[i];
        if (idx[i%2] == 0 || nums[idx[i%2]] < nums[i]) {
            idx[i%2] = i;
        }
        if (nums[i] > 0) {
            sum[i%2] += nums[i];
        }
    }
    if (nums[idx[0]] <= 0 && nums[idx[1]] <= 0) {
        if (nums[idx[0]] < nums[idx[1]]) {
            idx[0] = idx[1];
        }
        cout << nums[idx[0]] << '\n';
        cout << n-1 << '\n';
        for (int i = n; i > idx[0]; i--) {
            cout << i << '\n';
        }
        for (int i = 1; i < idx[0]; i++) {
            cout << "1\n";
        }
        return 0;
    }
    int p = 0;
    if (sum[1] > sum[0]) {
        p = 1;
    }
    vector<int> ret;
    list<LL> tmp;
    for (int i = 1; i <= n; i++) {
        if (i%2 != p || nums[i] <= 0) tmp.push_back(-1);
        else tmp.push_back(nums[i]);
    }
    while (tmp.size() > 1) {
        auto it = tmp.begin();
        int tot = 0;
        while (it != tmp.end()) {
            if (*it > 0) {
                tot++;
                it++;
                continue;
            }
            if (it == tmp.begin()) {
                ret.push_back(tot+1);
                it = tmp.erase(it);
                continue;
            }
            auto it1 = it; it1--;
            auto it2 = it; it2++;
            if (it2 == tmp.end()) {
                ret.push_back(tot+1);
                it = tmp.erase(it);
                continue;
            }
            if (*it1 > 0 && *it2 > 0 || *it1 < 0 && *it2 < 0) {
                *it1 += *it2;
                ret.push_back(tot+1);
                it = tmp.erase(it);
                it = tmp.erase(it);
                continue;
            }
            tot++;
            it++;
        }
    }
    cout << sum[p] << endl;
    cout << ret.size() << endl;
    for (int val : ret) {
        cout << val << endl;
    }
    assert(*tmp.begin() == sum[p]);
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();
        int r = 0;
        int cnt = 0;
        for(int i = Math.min(A, B);1 <= i;i--) {
        	if(A % i == 0 && B % i == 0) {
        		cnt++;
            	if(cnt >= K) {
            		r = i;
            		break;
            	}
        	}
        }
        System.out.println(r);
	}
}


Measured memory_bytes: 22868
#include<algorithm>
#include<iostream>
#include<queue>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	if(n<1200)
	{
		printf("ABC\n");
	}
	else if(n<2800)
	{
		printf("ARC\n");
	}
	else
	{
		printf("AGC\n");
	}
	return 0;
}

Measured memory_bytes: 256
# D - Knapsack 1
def solve_knapsack(weight_limit: int, weights: list, values: list) -> int:
    dp = [0] * (weight_limit + 1)  # dp[i] := optimum value at weight i
    for w, v in zip(weights, values):
        for cur_w in range(weight_limit, w - 1, -1):
            dp[cur_w] = max(dp[cur_w], dp[cur_w - w] + v)
    return dp[-1]


def main():
    N, W, *WV = map(int, open(0).read().split())
    print(solve_knapsack(W, WV[::2], WV[1::2]))


if __name__ == "__main__":
    main()


Measured memory_bytes: 39664
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static readonly int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			//string s = Console.ReadLine();
			int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			int[] h = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();

			SegTree<long> dp = new SegTree<long>(n + 1, 0, Math.Max);
			// dp[j] = k : 高さ j の時の最大価値 k
			for (int i = 0; i < n; i++) {   // i番目の花
				dp[h[i]] = dp.Query(0, h[i]) + a[i];
				//System.Diagnostics.Debug.WriteLine($"{i} = h:{h[i]} a:{a[i]}");
				//System.Diagnostics.Debug.WriteLine(dp.GetTreeString());
			}
			long ans = dp.Query();
			Console.WriteLine(ans);


			Console.Out.Flush();
		}
	}

	#region セグメント木
	public class SegTree<T>
	{
		private readonly T INF;
		private readonly T[] nodes;
		private readonly int length;
		private readonly int size;
		private readonly Func<T, T, T> update;
		private readonly Func<T, T, T> operation;

		public SegTree(int capacity, T inf, Func<T, T, T> query) : this(capacity, inf, query, (x, y) => y) { }
		public SegTree(int capacity, T inf, Func<T, T, T> query, Func<T, T, T> update)
		{
			long n = 1;
			while (n < capacity) {
				n *= 2;
			}
			INF = inf;
			nodes = new T[2 * n - 1];
			length = capacity;
			size = (int)n;
			this.update = update;
			operation = query;
			if (!INF.Equals(nodes[0])) {
				for (int i = 0; i < nodes.Length; i++) {
					nodes[i] = INF;
				}
			}
		}

		public T this[int i]
		{
			set { Update(i, value); }
			get { return nodes[size - 1 + i]; }
		}

		public void Update(int index, T value)
		{
			int i = size - 1 + index;
			nodes[i] = update(nodes[i], value);
			while (i > 0) {
				i = (i - 1) / 2;
				nodes[i] = operation(nodes[i * 2 + 1], nodes[i * 2 + 2]);
			}
		}

		public T Query()
		{
			return Query(0, length, 0, 0, size);
		}
		public T Query(int a, int b)
		{
			return Query(a, b, 0, 0, size);
		}
		public T Query(int a, int b, int k, int l, int r)
		{
			if (r <= a || b <= l) { return INF; }
			if (a <= l && r <= b) { return nodes[k]; }
			var c1 = Query(a, b, k * 2 + 1, l, (r + l) / 2);
			var c2 = Query(a, b, k * 2 + 2, (r + l) / 2, r);
			return operation(c1, c2);
		}
	}
	#endregion

}


Measured memory_bytes: 47636
from collections import deque
N = input().split()
d = deque(N)
ans = "NO"
while(len(d)>0):
    tmp = d.pop()
    if len(tmp) < 4:
        for i in N:
            d.append(tmp+i)
    else:
        if tmp == "1974":
            ans = "YES"
            break
print(ans)

Measured memory_bytes: 3444
def factor(N):
    res = []
    for i in range(1,int(N**0.5)+1):
        if N%i == 0:
            res.append(i)
            res.append(N//i)
    return sorted(list(set(res)))

N = int(input())
f = factor(N)
f.pop(0)

ans = 0
for n in f:
    tmp = n-1
    if N//tmp == N%tmp:
        ans += tmp
        
print(ans)

Measured memory_bytes: 10044
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
struct stu{
	int x;
	long long y;
	int z;
};
stu  c[120000];
int cmp(stu xx,stu yy){
	if(xx.x==yy.x)
	return xx.y<yy.y;
	else
	return xx.x<yy.x;
}
int cmpp(stu xxx,stu yyy)
{
	return xxx.z<yyy.z;
}
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		cin>>c[i].x>>c[i].y;
		c[i].z=i+1;
	}
	sort(c,c+m,cmp);
	int ok=c[0].x;
	c[0].y=1;
	long long  t=2;
	for(int i=1;i<m;i++)
	{
		if(c[i].x!=ok)
		{
			t=1;
			ok=c[i].x;
		}
		c[i].y=t++;
	}
	sort(c,c+m,cmpp);
	for(int i=0;i<m;i++)
	{
		printf("%06d%06d\n",c[i].x,c[i].y);
	}
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define setval(arr,v) memset(arr,v,sizeof(arr));
#define lli long long int
#define ll long long
#define mod 1000000007
#define v vector
#define pb push_back
#define pf pop_front;
#define fi first
#define se second
using namespace std;

void solve()
{
    int n,cnt = 0;
    cin>>n;
    int a[n];
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for (int i = 0; i < n; ++i)
    {
        for (int j = i+1; j < n; ++j)
        {
            for (int k = j+1; k < n; ++k)
            {
                if((a[i]+a[j] > a[k]) && a[i] != a[j] && a[j] != a[k] && a[k] != a[i])
                    cnt++;
            }
        }
    }
    cout<<cnt;



    
}


int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t = 1;
    // cin>>t;
    while(t--)
    {
        solve();

    }
    return 0;

}



Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define ll long long
#define P pair<int, int>

using namespace std;
int mod = 1000000007;

int N;

int main() {
  cin >> N;

  int sum = 0;
  int smallest = INT_MAX;
  rep(i, N) {
    int s; cin >> s;
    sum += s;
    if (s%10 != 0) {
      smallest = min(smallest, s);
    }
  }
  
  if (sum%10 == 0) {
    sum -= smallest;
    if (smallest == INT_MAX) {
      cout << 0 << endl;
      return 0;
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
//start of jonathanirvings' template v3.0.3 (BETA)

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

typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<LL> vl;
typedef vector<vl> vvl;

double EPS = 1e-9;
int INF = 1000000005;
long long INFF = 1000000000000000005LL;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

#ifdef TESTING
  #define DEBUG fprintf(stderr,"====TESTING====\n")
  #define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
  #define debug(...) fprintf(stderr, __VA_ARGS__)
#else
  #define DEBUG 
  #define VALUE(x)
  #define debug(...)
#endif

#define FOR(a,b,c) for (int (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define FORD(a,b,c) for (int (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (int (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define REP(i,n) FOR(i,0,n)
#define REPN(i,n) FORN(i,1,n)
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define SQR(x) ((LL)(x) * (x))
#define RESET(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(),v.end()
#define ALLA(arr,sz) arr,arr+sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr,sz) sort(ALLA(arr,sz))
#define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)

inline string IntToString(LL a){
  char x[100];
  sprintf(x,"%lld",a); string s = x;
  return s;
}

inline LL StringToInt(string a){
  char x[100]; LL res;
  strcpy(x,a.c_str()); sscanf(x,"%lld",&res);
  return res;
}

inline string GetString(void){
  char x[1000005];
  scanf("%s",x); string s = x;
  return s;
}

inline string uppercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
  return s;
}

inline string lowercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
  return s;
}

inline void OPEN (string s) {
  #ifndef TESTING
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
  #endif
}

//end of jonathanirvings' template v3.0.3 (BETA)

int n;
LL data[100005];

LL solve()
{
  LL res = 0;
  LL nowsum = 0;
  REP(i,n)
  {
    if (i % 2 == 0) {
      if (nowsum + data[i] <= 0)
      {
        res += llabs(nowsum + data[i] - 1);
        nowsum = 1;
      } else nowsum += data[i];
    } else {
      if (nowsum + data[i] >= 0)
      {
        res += llabs(nowsum + data[i] - (-1));
        nowsum = -1;
      } else nowsum += data[i];
    }
  }
  return res;
}

int main()
{
  scanf("%d",&n);
  REP(i,n) scanf("%lld",&data[i]);
  LL ans = solve();
  REP(i,n) data[i] *= -1;
  MIN(ans,solve());
  printf("%lld\n",ans);
  return 0;
}










Measured memory_bytes: 1024
//Splitting Pile

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll, string>;
using garph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    nvarep(n,a);
    ll arai=a[n-1],sunuke=accumulate(range(a),0LL)-a[n-1];
    ll mi=abs(arai-sunuke);
    rep(i,1,n-1){
        arai+=a[n-1-i];
        sunuke-=a[n-1-i];
        mi=min(mi,abs(arai-sunuke));
    }
    cout<<mi<<nnn;
    return 0;
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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 = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

vll a(16);
vector<pair<ll,bool>> s[16];

ll bitcount(ll x){
  if(x==0) return 0;
  return bitcount(x>>1)+(x&1);
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  rep(i,n){
    cin>>a[i];
    rep(j,a[i]){
      ll x,y; cin>>x>>y; x--;
      s[i].emplace_back(x,y);
    }
  }
  
  ll ans=0;
  for(ll bit=0; bit<(1<<n); bit++){
    bool ok=true;
    rep(i,n){
      if(bit&(1<<i)){
        rep(j,a[i]){
          ll x=s[i][j].first; bool y=s[i][j].second;
          bool target=bit&(1<<x);
          if(target){
            if(!y){
              ok=false;
              break;
            }
          }else{
            if(y){
              ok=false;
              break;
            }
          }
        }
      }
    }
    if(ok) {
      // cout<<bit<<endl;
      chmax(ans,bitcount(bit));
    }
  }
  cout<<ans<<endl;
}

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

#define int long long

int modpow(int x, int y, int z) { int a = 1; while (y > 0) { if (y & 1) a = a * x % z; x = x * x % z; y /= 2; } return a; }

const int M = 998244353;
int a[300];
int d[90310];
int e[90310];

signed main() {
  int n;
  scanf("%lld", &n);
  int sum = 0;
  d[0] = 1;
  for (int i = 0; i < n; ++i) {
    scanf("%lld", a + i);
    for (int t = sum; t >= 0; --t) {
      d[t + a[i]] += d[t];
      (d[t] *= 2) %= M;
    }
    sum += a[i];
  }
  int ans = modpow(3, n, M);
  for (int t = (sum + 1) / 2; t <= sum; ++t) {
    ans = (ans - d[t] * 3) % M;
  }
  if ((sum & 1) == 0) {
    int u = 0;
    e[0] = 1;
    for (int i = 0; i < n; ++i) {
      for (int t = min(sum / 2, u + 1); t >= 0; --t) {
        int *p = e + t + a[i];
        *p += e[t];
        if (*p >= M) *p -= M;
      }
      u += a[i];
    }
    ans = (ans + e[sum / 2] * 3) % M;
  }
  ans = (ans + M) % M;
  printf("%lld", ans);
}

Measured memory_bytes: 1280
#include<stdio.h>
#include<iostream>
#include<string>
#include<math.h>

using namespace std;

int LCM(int a, int b) {
	int i = 2;
	int gcd = 1;
	
	while (i <= a && i <= b) {
		if (a % i == 0 && b % i == 0) {
			gcd *= i;
			a /= i;
			b /= i;
		}
		else i++;
	}
	return a * b * gcd;

}

int main(){


	int size;
	cin >> size;
	int* a;
	a = new int[size];

	for (int i = 0; i < size; i++) {
		cin >> a[i];
	}

	int result = 1;
	for (int i = 0; i < size; i++) {
		result = LCM(result, a[i]);
	}
	cout << result << endl;
	//system("pause");
	return 0;
	
}




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

using ld=long double;
using P=complex<ld>;
using Poly=vector<P>;
const ld EPS=1e-9;
struct Line{
    P x,y;
};
ld cross(P x,P y){
    return real(x)*imag(y)-real(y)*imag(x);
}
P is_ll(Line s,Line t){
    return s.x+(s.y-s.x)*cross(t.x-s.x,t.y-s.x)/(cross(t.x-s.x,s.y-s.x)+cross(s.y-s.x,t.y-s.x));
}
enum{CCW,CW,ABC,ACB,BAC};
int ccw(P a,P b,P c){
    if(cross(a-b,c-b)>EPS) return CW;
    else return CCW;
}
vector<Line> shrink(Poly poly,ld len){
    int n=poly.size();
    vector<Line> res(n);
    for(int i=0;i<n;i++){
        Line org={poly[i],poly[(i+1)%n]};
        P vec=(org.y-org.x)*P(0,1);
        vec*=len/abs(vec);
        res[i]={org.x+vec,org.y+vec};
    }
    return res;
}

const int LOOP=50;
ld solve(int n){
    Poly poly(n);
    for(int i=0;i<n;i++){
        ld x,y;
        cin>>x>>y;
        poly[i]={x,y};
    }
    ld lb=0;
    ld ub=1e5;
    for(int _t=0;_t<LOOP;_t++){
        ld mid=(lb+ub)/2;
        vector<Line> sl=shrink(poly,mid);
        vector<P> pv;
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                Line s=sl[i];
                Line t=sl[j];
                if(abs(cross(s.x-s.y,t.x-t.y))>EPS){
                    pv.push_back(is_ll(s,t));
                }
            }
        }
        bool isok=true;
        for(auto p:pv){
            isok=true;
            for(int i=0;i<n;i++){
                int flag=ccw(sl[i].x,sl[i].y,p);
                if(flag==CW){
                    isok=false; break;
                }
            }    
            if(isok){
                break;
            }
        }
        if(isok) lb=mid;
        else ub=mid;
    }
    return lb;
} 
int main(){
    int n;
    while(cin>>n,n){
        cout<<setprecision(10)<<fixed;
        cout<<solve(n)<<endl;
    }
    return 0;
}


Measured memory_bytes: 3556
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class61
    {
        static void Main()
        {
            string abcd = Console.ReadLine();

            int ans = 0;
            for(int bit = 0; bit < (1 << abcd.Length); bit++)
            {
                int sum = int.Parse(abcd[0].ToString());
                for(int i=1;i<abcd.Length; i++)
                {
                    if ((bit & (1 << i-1)) != 0)
                        sum += int.Parse(abcd[i].ToString());
                    else sum-=int.Parse(abcd[i].ToString());
                }
                if (sum == 7)
                {
                    for(int i = 0; i < 4 - 1; i++)
                    {
                        Console.Write(abcd[i]);
                        if ((bit & (1 << i)) != 0) Console.Write("+");
                        else Console.Write("-");
                    }
                    Console.WriteLine($"{abcd[3]}=7");
                    return;
                }
            }
        }
    }
}


Measured memory_bytes: 13140
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
 
    //https://atcoder.jp/contests/dp/tasks/dp_c
    public static void main( String[] args ) {
 
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
 
        int[][] arr = new int[n][3];
        for (int i = 0; i < n; i++) {
            arr[i][0] = scanner.nextInt();
            arr[i][1] = scanner.nextInt();
            arr[i][2] = scanner.nextInt();
        }
 
       /* int[] dp = new int[3];
 
        Arrays.fill(dp, -1);
        int val = dfs(arr, 1, dp);
 
        System.out.println(val);*/
 
        int[][] dp = new int[n][3];
        for (int[] ay : dp)
            Arrays.fill(ay, -1);
 
        int ans = Math.max(solveTopDown(0, 0, arr, dp)
                , Math.max(solveTopDown(0, 1, arr, dp)
                        , solveTopDown(0, 2, arr, dp)));
 
        System.out.println(ans);
 
    }
 
private static int solveTopDown( int row, int curSelection, int[][] arr, int[][] dp ) {
        if (row >= arr.length)
            return 0;
 
        if (dp[row][curSelection] == -1) {
 
            int max = Integer.MIN_VALUE;
 
            //At each day Taro can do 3 activities...
            for (int j = 0; j < 3; j++) {
 
                //Next day activity should be different from Cur-selected Activity
                //For eg: during first function call we did : solveTopDown(0, 0, arr, dp)
                //here curSelection=0, so Taro can only choose from {1,2} activities to gain Max happiness.
                if (curSelection != j) {
 
                    int choice = solveTopDown(row + 1, j, arr, dp) + arr[row][j];
 
                    if (max < choice)
                        max = choice;
                }
            }
 
            dp[row][curSelection] = max;
        }
 
        return dp[row][curSelection];
    }
}

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

int main(int argc, const char * argv[]) {
    int H, W, i1, i2, flag;
    
    while(true){
        cin >> H >> W;
        flag = 0;
        
        if(H==0 && W==0)
            break;
        
        for(i1=0;i1<H;i1++){
            for(i2=0;i2<W;i2++){
                if(flag==0){
                    cout << "#";
                    flag=1;
                }else if(flag==1){
                    cout << ".";
                    flag=0;
                }
            }
            if(W%2==0){
                if(flag==0){
                    flag = 1;
                }else if(flag==1){
                    flag = 0;
                }
            }
            cout << endl;
        }
        cout << endl;
        
    }
    
    return 0;
}



Measured memory_bytes: 3092
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int dp[][] = new int[N][3];
        for(int i=0;i<N;i++){
            int a = Integer.parseInt(sc.next());
            int b = Integer.parseInt(sc.next());
            int c = Integer.parseInt(sc.next());
            if(i==0){
                dp[i][0] = a;
                dp[i][1] = b;
                dp[i][2] = c;
            }else{
                dp[i][0] = Math.max(dp[i-1][1]+a, dp[i-1][2]+a);
                dp[i][1] = Math.max(dp[i-1][0]+b, dp[i-1][2]+b);
                dp[i][2] = Math.max(dp[i-1][0]+c, dp[i-1][1]+c);
            }
        }
        System.out.println(Math.max(Math.max(dp[N-1][0],dp[N-1][1]),dp[N-1][2]));
    }
}


Measured memory_bytes: 66684
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    if (a == b)
        cout << a + b;
    else
        cout << 2 * max(a, b) - 1;
}


Measured memory_bytes: 256
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
int n,w[1004],s[1003],v[1003];
ll f[20005];
pair<int,int> p[1003];
void u(ll &x,ll y){
    if(y>x)x=y;
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;++i)scanf("%d%d%d",w+i,s+i,v+i),p[i]=mp(w[i]+s[i],i);
    sort(p+1,p+n+1);
    for(int i=1;i<=n;++i){
        int k=p[i].second;
        for(int j=s[k];j>=0;--j)u(f[j+w[k]],f[j]+v[k]);
    }
    ll ans=0;
    for(int i=1;i<=20000;++i)ans=max(ans,f[i]);
    printf("%lld\n",ans);
	//system("pause");
	return 0;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main() {
    long long int x;
    cin >> x;
    if(x<=6) {
        cout << 1 << endl;
    } else {
        if(x%11==0) {
            cout << x/11*2 << endl;
        } else if(x%11<=6) {
            cout << x/11*2+1 << endl;
        } else {
            cout << x/11*2+2 << endl;
        }
    }



    return 0;
    
}

Measured memory_bytes: 256