akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main{
	public void run(){
		Scanner scan = new Scanner(System.in);
		while(true){
			int x1 = scan.nextInt();
			int y1 = scan.nextInt();
			int x2 = scan.nextInt();
			int y2 = scan.nextInt();
			int x3 = scan.nextInt();
			int y3 = scan.nextInt();
			if(x1==0 && y1==0 && x2==0 && y2==0 && x3==0 && y3==0) break;
			double ab = Math.sqrt(Math.pow(x1-x2,2)+Math.pow(y1-y2,2));
			double bc = Math.sqrt(Math.pow(x2-x3,2)+Math.pow(y2-y3,2));
			double ca = Math.sqrt(Math.pow(x3-x1,2)+Math.pow(y3-y1,2));
			double s =  (ab+bc+ca)/2;
			double scale = Math.sqrt(s*(s-ab)*(s-bc)*(s-ca));
			double r = scale/s;
			double h=0;
			double arad=0;
			double brad=0; 
			double crad=0;
			if(ab>=bc && ab>=ca){
				h=2*(scale/ab);
				brad = Math.asin(h/ca);
				crad = Math.asin(h/bc);
				arad = Math.PI-(brad+crad);
			}
			else if(bc>=ab && bc>=ca){
				h=2*(scale/bc);
				arad = Math.asin(h/ca);
				crad = Math.asin(h/ab);
				brad = Math.PI-(arad+crad);
			}
			else if(ca>=ab && ca>=bc){
				h=2*(scale/ca);
				arad = Math.asin(h/bc);
				brad = Math.asin(h/ab);
				crad = Math.PI-(arad+brad);
			}
			/*
			double arad = Math.atan(ab/bc);
			double brad = Math.atan(bc/ca);
			double crad = Math.atan(ca/ab);
			*/
			double r1 = (r*(1+Math.tan(brad/4))*(1+Math.tan(crad/4)))/(2*(1+Math.tan(arad/4)));
			double r2 = (r*(1+Math.tan(arad/4))*(1+Math.tan(crad/4)))/(2*(1+Math.tan(brad/4)));
			double r3 = (r*(1+Math.tan(arad/4))*(1+Math.tan(brad/4)))/(2*(1+Math.tan(crad/4)));
			//System.out.println(ab+":"+bc+":"+ca);
			//System.out.println(arad+":"+brad+":"+crad);
			//System.out.println(r);
			/*
			double[] array = new double[3];
			array[0] = r1;
			array[1] = r2;
			array[2] = r3;
			Arrays.sort(array);
			System.out.println(array[0]+" "+array[1]+" "+array[2]);
			*/
			System.out.println(r2+" "+r3+" "+r1);
		}
	}

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

Measured memory_bytes: 45484
#include <iostream>
#include <vector>
#define min(a,b) ((a<b)?a:b)
#define max(a,b) ((a>b)?a:b)
using namespace std;

int main() {
	long long int N,A[100010],B[100010],ans=0;
	cin>>N;
	for(int i=0; i<=N; i++){
		cin>>A[i];
	}
	for(int i=0; i<N; i++){
		cin>>B[i];
	}
	for(int i=N-1; i>=0; i--){
		ans += min(A[i]+A[i+1],B[i]);
		A[i] = min(A[i],max(A[i]+A[i+1]-B[i],0));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<vector<double>> vvd;
typedef vector<double> vd;

#define debugone(x) cerr << #x << " " << x << "\n"; cerr.flush();
#define debugtwo(x) cerr << #x << "-------------" << "\n";for(auto &it: x) cerr << it << " ";cerr << "\n"; cerr.flush();
#define debugthree(x_, i_, j_) cerr << #x_ << "------------" << "\n";cerr << "from " << i_ << " to " << j_ << "\n";for(ll k_=i_; k_<=j_; k_++) cerr << x_[k_] << " ";cerr << "\n"; cerr.flush();
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

const ll MOD = 1e9 + 7;
const int INF = 2e9;
const int MAX_LOG = 21;
const int MAX_N = 1000*1001;

#define forn(i, n) for(int i = 0; i < n; i++)
#define forsn(i, s, n) for(int i = s; i < n; i++)
#define all(x) x.begin(), x.end()


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int h, n;
	cin >> h >> n;
	vi a(n);
	forn(i, n) cin >> a[i];
	int sum = 0;
	forn(i, n) sum += a[i];
	cout << ((sum >= h) ? "Yes" : "No") << endl;
}		


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define For(i,n) for(int i=0;i<n;i++)
#define Fre(i,a,b) for(int i = a; i < b; i++)
#define sf(n) scanf("%d", &n)
#define sff(a,b) scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define pfn(n) printf("%d\n", n)
#define pfs(n) printf("%d ", n)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define READ freopen("in.txt", "r", stdin)
#define WRITE freopen("out.txt", "w", stdout)
#define sz size()
#define number_of_digit(n) __builtin_ffs(n);
#define ll long long
#define T int
#define ld long double
inline void print(T n)
{
  if (n == 0)
  {
    putchar('0');
    putchar('\n');
  }
  else if (n == -1)
  {
    putchar('-');
    putchar('1');
    putchar('\n');
  }
  else
  {
    char buf[11];
    buf[10] = '\n';
    int i = 9;
    while (n)
    {
      buf[i--] = n % 10 + '0';
      n /= 10;
    }
    while (buf[i] != '\n')
      putchar(buf[++i]);
  }
}
int read()
{
       int cc = getc(stdin);
       for (;cc < '0' || cc > '9';)  cc = getc(stdin);
       int ret = 0;
       for (;cc >= '0' && cc <= '9';)
       {
          ret = ret * 10 + cc - '0';
          cc = getc(stdin);
       }
      return ret;
}
ll power(ll num,ll g)
{
  if(g==0)return 1;

  if(g%2==1)return (num*power((num*num),g/2));
  return power((num*num),g/2);
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  string s;
  cin>>s;
  int n=0;
  n=(s[0]-'0')*1000+(s[1]-'0')*100+(s[2]-'0')*10+(s[3]-'0');
  if(n<2019)
  {
    cout<<"Heisei\n";
    return 0;
  }
  if(n>2019)
  {
    cout<<"TBD\n";
    return 0;
  }
  n=0;
  n=(s[5]-'0')*10+(s[6]-'0');
  if(n<=4)
  {
    cout<<"Heisei\n";
    return 0;
  }
  if(n>4)
  {
    cout<<"TBD\n";
    return 0;
  }
  // n=(s[8]-'0')*10+(s[9]-'0');
  return 0;
}

Measured memory_bytes: 256
parseInt(x)=parse(Int, x)
parseMap(x::Array{SubString{String},1})=map(parseInt, x)

function main()
	n,k = readline() |> split |> parseMap
	a = readline() |> split |> parseMap
	for i in k+1:n
		println(a[i]>a[i-k] ? "Yes" : "No")
	end
end

main()

Measured memory_bytes: 194152
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
 
int main(void) {
    int a, b;
    int money = 0;
    cin >> a >> b;
    if(13 <= a){
        money += b;
    }else if(6 <= a){
        money += b / 2;
    }
    cout << money << endl;
    return 0;
}


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

int h, m, s;

void watch(int sec){
    int a;//余り
    h = sec / 3600;
    a = sec % 3600;
    m = a / 60 ;
    s = a % 60;
    
}

int main(int argc, const char * argv[]) {
    int sec;
    cin >> sec;
    watch(sec);
    cout << h << ":" << m << ":" << s << endl;
    return 0;
}


Measured memory_bytes: 3108
#include<iostream>
using namespace std;
int gcd(int a,int b,int c)
{
    while(a!=b)
    {
        if(a>b)
            a-=b;
        else
            b-=a;
    }
    while(a!=c)
    {
        if(a>c)
            a-=c;
        else
            c-=a;
    }

    return a;
}
int main()
{
    int i,j,k,n,sum=0,ans;
    cin >> n;
    for(i=1; i<=n; i++)
    {
        for(j=1; j<=n; j++)
        {
            for(k=1; k<=n; k++)
            {
                ans=gcd(i,j,k);
                sum+=ans;
            }
        }
    }
    cout << sum;
}


Measured memory_bytes: 3632
use std::io::{BufRead, Read};

pub struct Scanner<R>
where
    R: BufRead,
{
    reader: R,
}

impl<R> Scanner<R>
where
    R: BufRead,
{
    pub fn new(reader: R) -> Self {
        Self { reader }
    }

    pub fn next<T>(&mut self) -> T
    where
        T: ::std::str::FromStr,
        <T as ::std::str::FromStr>::Err: ::std::fmt::Debug,
    {
        self.reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .unwrap()
    }
}

fn main() {
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let mut sc = Scanner::new(stdin);

    loop {
        let m: i32 = sc.next();
        let f: i32 = sc.next();
        let r: i32 = sc.next();


        let score = match (m, f, r) {
            (-1,-1,-1) => break,
            (-1, _, _) | (_, -1, _) => "F",
            _ if m + f >= 80 => "A",
            _ if m + f >= 65 => "B",
            _ if m + f >= 50 => "C",
            _ if m + f >= 30 && r >= 50 => "C",
            _ if m + f >= 30 => "D",
            _ => "F",
        };
        println!("{}", score);
    }
}



Measured memory_bytes: 5028
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;

#define int long long

#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define rrep(i, n) for (int i=(int)n-1;i>=0;--i)
#define rrep1(i, n) for (int i=n;i>=1;--i)
#define range(i, l, r) for (int i=l;i<(int)r;++i)
#define rrange(i, l, r) for (int i=(int)r-1;i>=(int)l;--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using ll=long long;
using vi=vector<int>;
using pii=pair<int, int>;
using ld=long double;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
constexpr int TEN(int n){return n==0?1:10*TEN(n-1);}

const int mod = TEN(9)+7;
const int inf = TEN(18) * 3 + 10;

int N;
vi A;

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

	int ans = 0;

	rep(i, N) {
		if (A[i] >= 2) {
			if (A[i] & 1) {
				ans += A[i] / 2;
				A[i] = 1;
			} else {
				ans += (A[i] - 2) / 2;
				A[i] = 2;
			}
		}
	}

	rep(i, N) {
		ans += A[i] / 2;
		A[i] %= 2;

		if (i + 1 < N) {
			if (A[i] >= 1 and A[i + 1] >= 1) {
				int m = min(A[i], A[i + 1]);
				ans += m;
				A[i] -= m;
				A[i + 1] -= m;
			}
		}
	}

	cout << ans << endl;
}



Measured memory_bytes: 1024
/**
 * Created by hiramekun at 02:12 on 2020-05-10.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */
class UnionFind {
private:
    vector<ll> size; // グループに属する物の数．
public:
    vector<ll> par; // 親
    vector<ll> rank; // 木の深さ
    ll groupCount;

    explicit UnionFind(unsigned int n) {
        par.resize(n);
        rank.resize(n);
        size.resize(n);
        groupCount = n;
        rep(i, n) {
            par[i] = i;
            rank[i] = 0;
            size[i] = 1;
        }
    }

    // 木の根を求める
    ll find(ll x) {
        if (par[x] == x) {
            return x;
        } else {
            return par[x] = find(par[x]);
        }
    }

    // グループのサイズを求める．
    ll calc_size(ll x) {
        return size[find(x)];
    }

    // xとyの属する集合を併合
    void unite(ll x, ll y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        groupCount--;
        if (rank[x] < rank[y]) {
            par[x] = y;
        } else {
            par[y] = x;
            if (rank[x] == rank[y]) rank[x]++;
        }
        size[x] = size[y] = size[x] + size[y];
    }

    // xとyが同じ集合に属するか否か
    bool is_same(ll x, ll y) {
        return find(x) == find(y);
    }
};


void solve() {
    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> g[n];
    UnionFind u(n);
    rep(i, m) {
        ll a, b;
        cin >> a >> b;
        a--, b--;
        g[a].eb(b);
        g[b].eb(a);
        u.unite(a, b);
    }
    vector<ll> ans(n);
    rep(i, n) {
        ans[i] = u.calc_size(i) - 1;
        ans[i] -= g[i].size();
    }
    rep(i, k) {
        ll c, d;
        cin >> c >> d;
        c--, d--;
        if (u.is_same(c, d)) {
            ans[c]--, ans[d]--;
        }
    }
    cout << ans << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 10228
package main

import "fmt"
import "os"

var N int
var a []int
var touched map[int]bool

func main() {
	fmt.Scan(&N)
	a = make([]int, N+1)
	tmp := 0
	for i := 0; i < N; i++ {
		fmt.Scan(&tmp)
		a[i+1] = tmp
	}
	num := 0
	button := 1
	touched = make(map[int]bool)
	for a[button] != 2 {
		button = a[button]
		if _, ok := touched[button]; ok {
			fmt.Println("-1")
			os.Exit(0)
		}
		touched[button] = true
		num += 1
	}
	fmt.Println(num + 1)
}


Measured memory_bytes: 6912
// a,bを決めてcをにぶたんする cを最長とする
// sort.Searchのせいで4時間くらいバグらせた （対処法不明
package main
import (
	"fmt"
	"sort"
)
func main(){
	var N int
	fmt.Scan(&N)
	L := make([]int, N)
	for i:=0; i<N; i++{
		fmt.Scan(&L[i])
	}
	sort.Ints(L)
	ans := 0
	for a:=0; a<N-2; a++{
		for b:=a+1; b<N-1; b++{
			// cを最長とおいたのでb以上（for的にL[b]>=L[a]なので）

			// なぜかうまくいかない 多分以下のせい どこが悪いのか不明 ジャッジかパッケージがバグってるとしか思えない
			// c := sort.Search(N, func(j int)bool{
			// 	if L[a]+L[b] < L[j]{
			// 		return true
			// 	}
			// 	return false
			// })
			l, r := b, N
			for r>l{
				mid := (l+r)/2
				if L[a]+L[b] <= L[mid]{
					r = mid
				}else{
					l = mid+1
				}
			}
			c := l
			if c > b{
				ans += (c-1-b)
			}
		}
	}
	fmt.Println(ans)
}

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

const int MAXN = 1005;
const int MAXV = MAXN*(MAXN-1)/2;
vector<int> to[MAXV];
int id[MAXN][MAXN];
int toId(int i, int j) {
  if (i > j) swap(i,j);
  return id[i][j];
}

bool visited[MAXV];
bool calculated[MAXV];
int dp[MAXV]; // max length of path from v
int dfs(int v) {
  if (visited[v]) {
    if (!calculated[v]) return -1;
    return dp[v];
  }
  visited[v] = true;
  dp[v] = 1;
  for (int u : to[v]) {
    int res = dfs(u);
    if (res == -1) return -1;
    dp[v] = max(dp[v], res+1);
  }
  calculated[v] = true;
  return dp[v];
}

int main() {
  int n;
  cin >> n;
  vector<vector<int> > a(n, vector<int>(n-1));
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < n-1; j++) {
      cin >> a[i][j];
      a[i][j]--;
    }
  }
  int V = 0;
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < n; j++) {
      if (i < j) {
        id[i][j] = V++;
      }
    }
  }
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < n-1; j++) {
      a[i][j] = toId(i,a[i][j]);
    }
    for(int j = 0; j < n-2; j++) {
      to[a[i][j+1]].push_back(a[i][j]);
    }
  }
  int ans = 0;
  for(int i = 0; i < V; i++) {
    int res = dfs(i);
    if (res == -1) {
      puts("-1");
      return 0;
    }
    ans = max(ans, res);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 38528
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>

using namespace std;
typedef long long ll;

int main() {
    int M1, D1, M2, D2;
    cin >> M1 >> D1 >> M2 >> D2;
    if (D2 == 1) cout << 1 << endl;
    else cout << 0 << endl;
}

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

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;
 
#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;

int main() {
  
  int x;
  cin >> x;
  
  if ( x >= 30 ){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
  return 0;
  
}

Measured memory_bytes: 3628
N, Y = gets.split.map(&:to_i)
test = -> do
  0.step N do |i|
    y = Y
    m = N - i
    y -= i * 10000
    0.step m do |j|
      yy = y
      k = m - j
      yy -= j * 5000
      yy -= k * 1000
      return "#{i} #{j} #{k}" if yy == 0
    end
  end
  '-1 -1 -1'
end
puts test.()

Measured memory_bytes: 1916
#!/usr/bin/env python3
import sys
from collections import deque


def solve(N: int, path):
    f, s = [1], [N]
    black = set([1])
    white = set([N])
    while True:
        fn = []
        for ff in f:
            for fnext in path[ff]:
                if fnext not in white and fnext not in black:
                    black.add(fnext)
                    fn.append(fnext)
        f = fn
        sn = []
        for ss in s:
            for snext in path[ss]:
                if snext not in white and snext not in black:
                    white.add(snext)
                    sn.append(snext)
        s = sn
        if not s and not f:
            break
    print("Fennec" if len(black) > len(white) else "Snuke")
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    path = {}
    for i in range(N - 1):
        a = int(next(tokens))
        b = int(next(tokens))
        if a in path:
            path[a].append(b)
        else:
            path[a] = [b]
        if b in path:
            path[b].append(a)
        else:
            path[b] = [a]
    solve(N, path)

if __name__ == '__main__':
    main()


Measured memory_bytes: 32280
#include <stdio.h>

typedef struct { char suit, value; } Card;

void bubble(Card A[], int N) {
  int i,j;
  Card t;
  for(i = 0; i<N; i++) {
    for(j = N-1; j >= i; j--) {
      if(A[j].value < A[j-1].value) {
        t = A[j]; A[j] = A[j-1]; A[j-1] = t;
      }
    }
  }
}

void selection(Card A[], int N) {
  int i,j,minj;
  Card t;
  for(i=0;i<N;i++) {
    minj = i;
    for(j=i; j<N; j++) {
      if(A[j].value < A[minj].value) minj = j;
    }
    t = A[i]; A[i] = A[minj]; A[minj] = t;
  }
}

void print(Card A[], int N) {
  int i;
  for(i=0; i<N; i++) {
    if(i>0) printf(" ");
      printf("%c%d",A[i].suit,A[i].value);
  }
  printf("\n");
}

int isStable(Card C1[], Card C2[], int N) {
  int i;
  for(i=0; i<N; i++) {
    if(C1[i].suit != C2[i].suit) return 0;
  }
  return 1;
}

/* オリジナル関数を追加 */
void str2Card(Card *t,char str[]) {
    t->suit  = str[0];
    t->value = str[1] - '0';
}

int main(void) {
  Card C1[100], C2[100];
  int N,i;
  char str[3];

  scanf("%d",&N);
  for(i=0;i<N; i++) {
    scanf("%s",str);
    str2Card(&C1[i],str);
  }

  for(i=0; i<N; i++) C2[i] = C1[i];

  bubble(C1,N);
  selection(C2,N);

  print(C1,N);
  printf("Stable\n");
  print(C2,N);
  if(isStable(C1,C2,N)) {
    printf("Stable\n");
  } else {
    printf("Not stable\n");
  }

  return 0;
}


Measured memory_bytes: 2092
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
count = 0
tmp = 0
for i in range(N):
    tmp = min(A[i],B[i])
    count +=tmp
    tmp = min(A[i+1],B[i]-tmp)
    A[i+1] -=tmp
    count +=tmp
print(count)

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

int main(){
    int H,W,h,w;
    cin >> H >> W >> h >> w;
    cout << (H-h)*(W-w) << endl;
    return 0;
}

Measured memory_bytes: 256
S = input()
N = len(S)

def solve(N, S):
    
    if S == S[::-1]:
        # 回文である
        hoge = S[:int((N-1)/2)]
        hoge2 = S[int((N+3)/2)-1:N]
        
        if hoge == hoge[::-1] and hoge2 == hoge[::-1]:
            return "Yes"
    return "No"

print(solve(N, S))

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

int main() {
    vector<int> order(5);
    for(int i = 0; i < 5; i++) cin >> order[i];
    
    bool flg = false;
    for(int i = 1; i < 9; i++) {
        for(int j = 0; j < 5; j++) {
            if(order[j] % 10 == i) {
                flg = true;
                swap(order[j], order[4]);
                break;
            }
        }
        if(flg == true) break;
    }
    
    int rtn = 0;
    for(int i = 0; i < 4; i++) {
        rtn += order[i];
        int plus = 0;
        if (rtn % 10 != 0) {
            plus = 10 - (rtn % 10);
        }
        rtn += plus;
    }
    rtn += order[4];
    
    cout << rtn << endl;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<int>;
using vvi = vector<vi>;


//auto mod int
//https://github.com/atcoder-live/library/blob/master/mint.cpp

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
    int64_t x;
    mint(int64_t x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(int64_t t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    //for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) {return mint(*this) /= a;}
};

istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


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

    mint ans;
    vector<vector<mint> > dp(n+1, vector<mint>(k+1));
    vector<vector<mint> > sum(n+1, vector<mint>(k+1));
    
    dp[0][0] = 1;
    rep(i, k+1) {
        sum[0][i]  = 1;
    }
    rep(i, n) {
        rep(j, k+1) {
            if(j-a[i] > 0) {
                dp[i+1][j] = sum[i][j] - sum[i][j-a[i]-1];
            } else {
                dp[i+1][j] = sum[i][j];
            }
            if(!j) sum[i+1][0] = 1;
            else sum[i+1][j] = sum[i+1][j-1] + dp[i+1][j];
        }
    }

    cout << dp[n][k] << endl;
    
}

Measured memory_bytes: 161924
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long ans =0;

		Map<String,Long>strmap = new HashMap<String, Long>();

		for (int i = 0; i < N; i++) {
			char[] c = new char[10];
			c = sc.next().toCharArray();
			Arrays.sort(c);
			String let = String.valueOf(c);
			if (strmap.containsKey(let)) {
				strmap.put(let, strmap.get(let) + 1);
			} else {
				strmap.put(let, 1L);
			}
		}

		for (String string : strmap.keySet()) {
			long dub = strmap.get(string);
			ans += dub * (dub-1) / 2;
		}

		System.out.println(ans);

	}
}




Measured memory_bytes: 68752
#include<iostream>
#define Max(a,b) (a>b?a:b)
using namespace std;
const int MAXN = 1e5+10;
int dp[MAXN][4], A[MAXN], B[MAXN], C[MAXN], N;

int read() {
	int num=0;
	char c=getchar();
	while(c<'0' || c>'9') c=getchar();
	while(c>='0' && c<='9') num=(num<<3)+(num<<1)+(c^48),c=getchar();
	return num;
}

int main()
{
	N=read();
	int i, ans;
	for(i=1;i<=N;i++) {
		A[i]=read(), B[i]=read(), C[i]=read();
	}
	dp[1][1]=A[1], dp[1][2]=B[1], dp[1][3]=C[1];
	for(i=2;i<=N;i++) {
		dp[i][1] = Max(dp[i-1][2], dp[i-1][3])+A[i];
		dp[i][2] = Max(dp[i-1][1], dp[i-1][3])+B[i];
		dp[i][3] = Max(dp[i-1][1], dp[i-1][2])+C[i];
	}
	ans=Max(dp[N][1], Max(dp[N][2], dp[N][3]));
	cout<<ans;
	return 0;
}

Measured memory_bytes: 2944
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    int n,k;
    cin >> n >> k;
    ll a[n];
    inrep(n,a);
    sort(a,a+n);
   
    ll ans = linf;
    rep(i,0,n-k+1){
        ans = min(ans,a[i+k-1]-a[i]);
    }
    P(ans);
    
	return  0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int ans=1;
  int N;
  cin>>N;
  for(int i=0;i<N;i++)
  {
    int X;
    cin>>X;
    if(X==ans)
      ans++;
  }
  ans--;
  if(ans==0)
    puts("-1");
  else	cout<<N-ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#081b
import collections

N = int(input())
A_list = [int(e) for e in input().split()]

#https://note.nkmk.me/python-prime-factorization/
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

counted_list = [prime_factorize(A*2).count(2)-1 for A in A_list] #1だと空リストになるので*2の下駄をはかせて、-1で脱がす
print(min(counted_list))

Measured memory_bytes: 3316
#include <stdio.h>
 
int main(void)
{
    int i, N, K;
    char str[11];
    scanf("%d", &N);
    scanf("%s", str);
    scanf("%d", &K);

    for (i = 0; i < N; i++){
        if(str[i] == str[K - 1]){
            continue;
        }else{
            str[i] = '*';
        }
    }
    printf("%s\n", str);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


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

  int N, M;
  cin>>N>>M;

  vector<int> A(M);
  for(int i=0;i<M;i++){
    int k;
    cin>>k;
    int num = 0;
    for(int i=0;i<k;i++){
      int s;
      cin>>s; s--;
      num |= 1<<s;
    }
    A[i] = num;
  }

  vector<int> p(M);
  cin>>p;


  auto check = [&](int bit){

    for(int i=0;i<M;i++){
      int v = A[i] & bit;
      if(__builtin_popcount(v)%2 != p[i]) return false;
    }
    return true;
  };

  int ans = 0;
  for(int i=0;i<(1<<N);i++){
    ans += check(i);
  }

  cout<<ans<<endl;

  

  return 0;
}


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

public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] line = br.readLine().split(" ");
		int k = Integer.parseInt(line[0]);
		int x = Integer.parseInt(line[1]);
		
		StringBuilder sb = new StringBuilder();
		for(int i=0; i<2*k-1; i++){
			sb.append(x-k+1+i);
			sb.append(" ");
		}
		String result = sb.toString();
		System.out.println(result.substring(0, result.length()-1));
	}
}


Measured memory_bytes: 22996
#include<cstdio> 
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
using namespace std;
#define fo(i,j,k) for(i=j;i<=k;i++)
#define fd(i,j,k) for(i=j;i>=k;i--)
#define cmax(a,b) (a=(a>b)?a:b)
#define cmin(a,b) (a=(a<b)?a:b)
typedef long long ll;
const int N=1e6+5,M=2e6+5,mo=1e9+7;
int n,ans,i,x,y;
int tt,nxt[N],b[N],fst[N];
void cr(int x,int y)
{
	tt++;
	b[tt]=y;
	nxt[tt]=fst[x];
	fst[x]=tt;
}
int f[N],sat[N];
void dfs(int x,int y)
{
	int lwb=0;
	for(int p=fst[x];p;p=nxt[p])
		if (b[p]!=y)
		{
			dfs(b[p],x);
			lwb|=sat[x]&sat[b[p]];
			sat[x]|=sat[b[p]];
		}
	f[x]=0;
	while ((1<<f[x])<=lwb||((1<<f[x])&sat[x])) f[x]++;
	sat[x]=(sat[x]>>f[x]<<f[x])|(1<<f[x]);
	cmax(ans,f[x]);
}
int main()
{
	scanf("%d",&n);
	fo(i,1,n-1)
	{
		scanf("%d %d",&x,&y);
		cr(x,y);
		cr(y,x);
	}
	dfs(1,0);
	printf("%d\n",ans);
}

Measured memory_bytes: 20352
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
  double a,b,c,d,e,f;
  double x,y;
  
  while(cin >> a>>b>>c>>d>>e>>f)
    {
      x = (c*e - b*f)/(a*e - b*d);
      y = (c*d - a*f)/(b*d - a*e);

      if(x == 0)
	{
	  x = 0.000;
	}
      if(y == 0)
	{
	  y = 0.000;
	}
      
      
      printf("%.3f %.3f\n",x,y);
      
    }

  return 0;
}

      

Measured memory_bytes: 1236
import sys
import math

N = int(input())

list = []

for i in range(N):
    S, P = input().split()
    list.append((S, int(P), i+1))

list = sorted(list, key=lambda x:x[1],reverse = True) 
list = sorted(list, key=lambda x:x[0]) 
for j in range(N):
	print(list[j][2])


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

balls = []
for i in range(N):
    balls.append(list(map(int, input().split())))

X = []
for i in range(N-1):
    for j in range(i+1,N):
        X.append((balls[i][0] - balls[j][0], balls[i][1] - balls[j][1]))
        X.append((balls[j][0] - balls[i][0], balls[j][1] - balls[i][1]))


Y = set(X)
res = 0
for x in X:
    res = max(res, X.count(x))
print(N-res)

Measured memory_bytes: 39920
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <bits/stdc++.h>
#include <string>
using namespace std;

int main(){
    long N,M;
    cin>>N>>M;
    long long A[N];
    priority_queue<long long> que;
    for(long i=0;i<N;i++){
        long long A;cin>>A;que.push(A);
    }
    for(long i=0;i<M;i++){
        long long t = que.top();que.pop();
        que.push(t/2);
    }

    long long res=0;
    while(!que.empty()){
        res+=que.top();
        que.pop();
    }
    cout<<res<<endl;

}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w",stdout);
    #endif
    


    set<int> s1;
    set<int>s2;
    int n;
    cin>>n;
    s1.insert(2);
    s1.insert(4);
    s1.insert(5);
    s1.insert(7);
    s1.insert(9);
    s2.insert(0);
    s2.insert(1);
    s2.insert(6);
    s2.insert(8);

    if(n%10==3){
        cout<<"bon"<<endl;
    }else{
        if(s1.find(n%10) != s1.end()){
            cout<<"hon"<<endl;
        }else{
            cout<<"pon"<<endl;
        }
    }

    
}

Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n, t, a; cin >> n >> t >> a;
    int ans;
    int Min = 1<<30;
    // 気温を1000倍すると0.006で小数にならなくて済む
    rep(i,n) {
        int h; cin >> h;
        int tmp = t*1000 - h*(0.006*1000) - a*1000; // 地点平均-a
        int tmpAbs = abs(tmp);
        if (tmpAbs < Min)
        {
            Min = tmpAbs;
            ans = i;
        }
    }
    cout << ++ans << endl;
    return 0;
}

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

using namespace std;
int main(int argc, const char * argv[]) {
    
    int n;
    cin >> n;

    int c= (n>=105) ? 1 : 0;
    for(int i=107; i <= n; i = i + 2) {
        int ct = 1;
        for (int j=1; j<i; j++){
            if ( i % j == 0 ) ct++;
        }
        if (ct == 8) c+=1;
    }

    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

sys.setrecursionlimit(10**9)
N = int(input())


def main(s, o, n):
    n += 1
    if n == N:
        print(s)
    else:
        for i in range(97, o + 2):
            main(s + chr(i), max(o, i), n)


main("a", 97, 0)


Measured memory_bytes: 9196
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskF solver = new TaskF();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskF {
        static final long MODULO = (long) 1e9 + 7;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long[] invs = new long[Math.max(3, n) + 1];
            invs[1] = 1;
            for (int i = 2; i < invs.length; ++i) {
                invs[i] = (MODULO - invs[((int) (MODULO % i))] * (MODULO / i) % MODULO) % MODULO;
                if (invs[i] * i % MODULO != 1) throw new RuntimeException();
            }

            long[] e = new long[n + 1];
            long s = 0;
            for (int k = n; k >= 1; --k) {
                s = (s + invs[n] * invs[k]) % MODULO;
                e[k] = s;
            }

            long res = 0;
            long pw = 1;
            for (int k = 1; k <= n; ++k) {
                long g = e[k];
                if (k < n)
                    g -= e[k + 1];
                g += MODULO;
                g %= MODULO;
                pw = pw * 3 % MODULO;
                res = (res + g * pw) % MODULO;
            }
            for (int i = 1; i <= n + 1; ++i) {
                res = res * invs[3] % MODULO;
            }
            out.println(res);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 40276
package main

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

func main() {
	r := bufio.NewReader(os.Stdin)

	var n int
	fmt.Fscan(r, &n)

	max := -9999999999
	min := 9999999999
	for x := 0; x < n; x++ {
		var e int
		fmt.Fscan(r, &e)
		if max < e-min {
			max = e - min
		}
		if min > e {
			min = e
		}
	}
	fmt.Println(max)
}



Measured memory_bytes: 5868
#include <bits/stdc++.h>
#define REP(i, a, n) for (ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

class MaxFlow {
public:
  struct edge { ll to, cap, rev; };

  const ll INF = 1LL << 60;
  ll N;
  vector< vector<edge> > E;
  vector<bool> used;

  MaxFlow(ll n): N(n), E(n), used(n) {};

  void add_edge(ll from, ll to, ll cap) {
    E[from].push_back((edge) { to, cap, (ll) E[to].size() });
    E[to].push_back((edge) { from, 0, (ll) E[from].size() - 1 });
  }


  ll dfs(ll v, ll t, ll f) {
    if(v == t) return f;
    used[v] = true;
    REP(i, 0, E[v].size()) {
      edge &e = E[v][i];
      if(!used[e.to] && e.cap > 0) {
        ll d = dfs(e.to, t, min(f, e.cap));
        if(d > 0) {
          e.cap -= d;
          E[e.to][e.rev].cap += d;
          return d;
        }
      }
    }
    return 0;
  }

  ll max_flow(ll s, ll t) {
    ll flow = 0;
    while(1) {
      REP(i, 0, N) used[i] = false;
      ll f = dfs(s, t, INF);
      if(f == 0 || f == INF) break;
      flow += f;
    }
    return flow;
  }
};

int main(void) {
  ll R, C;
  cin >> R >> C;
  char S[50][50];
  REP(i, 0, R) REP(j, 0, C) cin >> S[i][j];

  const ll INF = 1LL << 50;
  MaxFlow mf(R * C * 3 + 2);
  ll s = R * C * 3, t = R * C * 3 + 1;
  ll b = 0, g = 0;
  REP(i, 0, R) REP(j, 0, C) if (S[i][j] == '#') {
    ll u = i * C + j;
    if (i + 1 < R && S[i + 1][j] == '#') {
      ll v = (i + 1) * C + j;
      ll w = i * C + j + R * C;
      mf.add_edge(w, t, 1);
      mf.add_edge(u, w, INF);
      mf.add_edge(v, w, INF);
      g++;
    }
    if (j + 1 < C && S[i][j + 1] == '#') {
      ll v = i * C + (j + 1);
      ll w = i * C + j + R * C * 2;
      mf.add_edge(s, w, 1);
      mf.add_edge(w, u, INF);
      mf.add_edge(w, v, INF);
      g++;
    }
    b++;
  }

  ll f = mf.max_flow(s, t);
  cout << b - (g - f) << endl;
}


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

using namespace std;

typedef long long ll;
typedef double dd;

const ll MAX = 111000;
bool can[MAX];

void solve(ll test_num) {
  (void) test_num;
  int N, Q;
  cin >> N >> Q;
  memset(can, false, sizeof(can));
  int ball = 1;
  can[1] = true;
  can[2] = true;
  for (int q = 0, a, b; q < Q; ++q) {
    cin >> a >> b;
    if (ball == a) {
      ball = b;
    } else if (ball == b) {
      ball = a;
    }
    swap(can[a], can[b]);
    can[ball - 1] = true;
    can[ball] = true;
    can[ball + 1] = true;
  }
  cout << count(can + 1, can + N + 1, true) << endl;
}

void init() {

}

int main() {
#ifdef AZN
  const auto start_time = chrono::system_clock::now();
  freopen("/home/azneye/Documents/Stuff/input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  init();
  ll tests = 1;
  //cin >> tests;
  for (ll test = 1; test <= tests; ++test) {
    solve(test);
  }
#ifdef AZN
  cerr << "Took: " << ((chrono::system_clock::now() - start_time).count() / 1e9) << " s" << endl;
#endif
  return 0;
}

Measured memory_bytes: 384
S = input()
T = input()

s = len(S)
t = len(T)


for i in range(s-t, -1, -1):
    n = 0
    for j in range(t-1, -1, -1):
        if S[j+i] != '?' and S[j+i] != T[j]:
            break
        n += 1

    if n == t:
        for x in range(s):
            if i <= x < i+t:
                print(T[x-i], end='')
            else:
                if S[x] == '?':
                    print('a', end='')
                else:
                    print(S[x], end='')
        exit()

print('UNRESTORABLE')


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

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

typedef long long ll;

using namespace std;
int main()
{
    int N;
    cin >> N;
    int A[101], B[101];
    REP(i, N - 1)
    {
        cin >> B[i];
    }

    int ans = 0;
    A[0] = B[0];
    A[N - 1] = B[N - 2];
    for (int i = 1; i < N - 1; i++)
    {
        A[i] = min(B[i - 1], B[i]);
    }

    REP(i, N)
    {
        ans += A[i];
    }

    cout << ans << endl;
}


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


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

    vector<char> ACGT = {'A','C','G','T'};

    vector<bool> ok(S.size(),false);

    for(int i=0;i<S.size();i++){
        for(int j=0;j<4;j++){
            if(S[i]==ACGT[j]){
                ok[i] = true;
            }
        }
    }

    int ans = 0,tmp = 0;

    for(int i=0;i<S.size();i++){
        if(ok[i])tmp++;
        if(!ok[i])tmp=0;
        if(ans<tmp) ans=tmp;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
program abc168C
    implicit none

    integer(8) :: a, b
    real(8) :: h, m
    real(8), parameter :: pi = 3.141592653589_8
    real(8) :: int1, int2, realp
    read(*,*) a, b, h, m
    
    int1 = real(a**2+b**2, kind=8)
    int2 = real(2*a*b, kind=8)
    realp = cos((h/6-m/30+m/360)*pi)

    write(*,*) sqrt(int1-int2*realp)

    stop
end program abc168C

Measured memory_bytes: 3304
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public string S;
        public int W;
        public void Run()
        {
            S = Console.ReadLine();
            W = Input.ReadInt();
            for (int i = 0; i < S.Length; i += W)
            {
                Console.Write(S[i]);
            }
            Console.WriteLine();
        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 11092