akhauriyash/Code-Regression huggingface dataset:
extern crate core;

use std::fmt;
use std::cmp::{Ordering, min, max};
use std::f32::MAX;
use std::ops::{Add, Sub, Mul, Div, Neg, Index, IndexMut, SubAssign, Range};
use std::collections::{BTreeMap, VecDeque, BinaryHeap, BTreeSet, HashMap};
use std::fmt::{Display, Formatter, Error};
use std::hash::{Hash, Hasher};

fn show<T: Display>(vec: &Vec<T>) {
    if vec.is_empty() {
        println!("[]");
    }else {
        print!("[{}", vec[0]);
        for i in 1 .. vec.len() {
            print!(", {}", vec[i]);
        }
        println!("]");
    }
}
fn show2<T: Display>(vec: &Vec<Vec<T>>) {
    if vec.is_empty() {
        println!("[]");
    }else {
        for l in vec {
            show(l);
        }
    }
}
macro_rules! read_line{
    () => {{
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).ok();
        line
    }};
    (delimiter: ' ') => {
        read_line!().split_whitespace().map(|x|x.to_string()).collect::<Vec<_>>()
    };
    (delimiter: $p:expr) => {
        read_line!().split($p).map(|x|x.to_string()).collect::<Vec<_>>()
    };
    (' ') => {
        read_line!(delimiter: ' ')
    };
    ($delimiter:expr) => {
        read_line!(delimiter: $delimiter)
    };
    (' '; $ty:ty) => {
        read_line!().split_whitespace().map(|x|x.parse::<$ty>().ok().unwrap()).collect::<Vec<$ty>>()
    };
    ($delimiter:expr; $ty:ty) => {
        read_line!($delimiter).into_iter().map(|x|x.parse::<$ty>().ok().unwrap()).collect::<Vec<$ty>>()
    };
}
macro_rules! read_value{
    () => {
        read_line!().trim().parse().ok().unwrap()
    }
}
macro_rules! let_all {
    ($($n:ident:$t:ty),*) => {
        let line = read_line!(delimiter: ' ');
        let mut iter = line.iter();
        $(let $n:$t = iter.next().unwrap().parse().ok().unwrap();)*
    };
}
macro_rules! let_mut_all {
    ($($n:ident:$t:ty),*) => {
        let line = read_line!(delimiter: ' ');
        let mut iter = line.iter();
        $(let mut $n:$t = iter.next().unwrap().parse().ok().unwrap();)*
    };
}

fn main() {
    let_all!(n: i32);
    let mut i = 1;
    loop {
        let mut count = 1;
        for j in 1 .. i {
            if i % j == 0 {
                count += 1;
            }
        }
        if count == n {
            break
        }else {
            i += 1;
        }
    }
    println!("{}", i);
}


Measured memory_bytes: 5032
import java.util.*;
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int k = sc.nextInt();
		int count_Bl=0;
		int result=0;
		int[][] board =new int[h][w];
		
		for(int i=0;i<h;i++){
			String input=sc.next();
			for(int j=0;j<w;j++){
				if(input.charAt(j)=='#'){
					board[i][j] = 1;
				}else{
					board[i][j] = 0;
				}

			}
		}  
		for(int i=0;i<Math.pow(2,h);i++){
			String paH=String.format("%6s",Integer.toBinaryString(i));
			for(int j=0;j<Math.pow(2,w);j++){
				String paW=String.format("%6s",Integer.toBinaryString(j));

				for(int n=0;n<h;n++){
					for(int m=0;m<w;m++){
						if(paH.charAt(6-h+n)!='1' && paW.charAt(6-w+m)!='1'){
							if(board[n][m]==1){
								count_Bl+=1;
							}
						}
					}   
				}
				if(count_Bl==k){
					result+=1;
				}
				count_Bl=0;
			} 
		}
		System.out.println(result);
	} 
}

Measured memory_bytes: 45824
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        int[] a = new int[n];
        int[] b = new int[n];
        int[] c = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
            c[i] = sc.nextInt();
        }
        //long start = System.nanoTime();
        System.out.println(solve(n, a,b,c));
        //long end = System.nanoTime();
        //System.err.println("execution time: " + ((end-start)/1_000_000) + "ms");
    }
    private static int solve(int n, int[] a, int[] b, int[] c) {
        int[][] dp = new int[n][3];
        dp[0][0] = a[0];
        dp[0][1] = b[0];
        dp[0][2] = c[0];
        for (int i = 1; i < n; i++) {
            for (int j = 0; j <3; j++) {
                for (int k = 0; k < 3; k++) {
                    if(k != j) {
                        dp[i][j] = Math.max(dp[i][j], dp[i-1][k] + compute(j,a,b,c)[i]);
                    }
                }
            }
        }
        return Math.max(dp[n-1][0], Math.max(dp[n-1][1], dp[n-1][2]));
    }
    private static int[] compute(int choice, int[] a, int[] b, int[] c) {
        switch (choice) {
            case 0: return a;
            case 1: return b;
            case 2: return c;
            default: return a;
        }
    }
}


Measured memory_bytes: 93700
#include<stdio.h>
#define MAX 30
int main(){
  int n,m;
  scanf("%d%d",&n,&m);
  int a[MAX]={},i,j,k,p;
  for(i=0;i<n;i++){
    scanf("%d",&k);
    for(j=0;j<k;j++){
      scanf("%d",&p);
      a[p-1]++;
    }
  }
  int ans=0;
  for(i=0;i<m;i++){
    if(a[i]==n)ans++;
  }
  printf("%d",ans);
}

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

int main() {
    int n;
    cin >> n;
    int ans = 0;
    for(int i=1; i<=n; i++) {
        if (i<10) {
            ans++;
        } else if(100<=i && i<1000){
            ans++;
        } else if(10000<=i && i<100000){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using vvii = vector<vector<int> >;
using vvll =  vector<vector<ll> >;

const ll inf = 1LL << 60;

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    int a; cin >>a;
    cout << a+ a*a + a*a*a << endl;
}

Measured memory_bytes: 3636
#include<iostream>
using namespace std;
const int N = 8;

int row[N], column[N], desup[2 * N], desdown[2 * N];
int T[N][N];
void initial()
{
    for(int i = 0; i < N; i++) { row[i] = 0; column[i] = 0;}
    for(int i = 0; i < 2*N; i++) {desup[i] = 0; desdown[i] = 0;}
    for(int i = 0; i < N; i++)
        for(int j = 0; j < N; j++)
            T[i][j] = 0;
}

void print()
{
    for(int i = 0; i < N; i++)
        for(int j = 0; j < N; j++)
            if(T[i][j])
            {
                if(row[i] != j)
                    return ;
            }
    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < N; j++)
            if(row[i] == j)
                cout << 'Q';
            else
                cout << '.';
        cout << endl;
    }
}
void solve(int i)
{
    if(i == N)
    {
        print();
        return ;
    }
    for(int j = 0; j < N; j++)
    {
        if(column[j] || desup[i+j] || desdown[i-j+N-1])
            continue;
        row[i] = j;
        column[j] = desup[i+j] = desdown[i-j+N-1] = 1;
        solve(i+1);
        row[i] = column[j] = desup[i+j] = desdown[i-j+N-1] = 0;
    }
}

int main()
{
    int n;
    cin >> n;
    initial();
    for(int i = 0; i < n; i++)
    {
        int x, y;
        cin >> x >> y;
        T[x][y] = 1;
    }
    solve(0);
    return 0;
}



Measured memory_bytes: 3112
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format, std.datetime;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N = lread();
    auto A = aryread();
    auto dp = new long[](N + 1);
    dp[0] = 1;
    foreach (i; 0 .. N)
        dp[i + 1] = dp[i] * ((A[i] % 2 == 0) + 1);
    writeln(3 ^^ N - dp[N]);
}


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

int N, M;

vector<bool> visited;
vector<vector<bool>> G;

void dfs(int v)
{
	visited[v] = true;
	rep(i, N)
	{
		if (!G[i][v]) continue;
		if (visited[i]) continue;

		dfs(i);
	}
}

int main()
{	
	cin >> N >> M;

	visited.resize(N);

	G.resize(N);
	rep(i, N) G[i].resize(N, false);

	vector<pair<int, int>> E(M);

	rep(i, M)
	{
		int a, b;
		cin >> a >> b;
		--a;
		--b;
		E[i].first = a;
		E[i].second = b;

		G[a][b] = G[b][a] = true;
	}

	ll count = 0;

	rep(i, M)
	{
		//橋を削除
		G[E[i].first][E[i].second] = G[E[i].second][E[i].first] = false;

		//探索フラグ初期化
		rep(j, N) visited[j] = false;

		dfs(0);

		//探索フラグチェック
		rep(j, N)
		{
			if (!visited[j])
			{
				count++;
				break;
			}
		}

		//橋を戻す
		G[E[i].first][E[i].second] = G[E[i].second][E[i].first] = true;
	}

	cout << count << endl;

	return 0;
}

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

LL dp[100010];

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

  int N, K; cin >> N >> K;
  vector<LL> xs(N);
  REP(i,N) cin >> xs[i];
  vector<LL> acc(N+1);
  vector<LL> pos(N+1);
  REP(i,N){
	acc[i+1] = acc[i] + xs[i];
	pos[i+1] = pos[i] + max(xs[i], 0LL);
  }
  
  LL ans = 0;
  REP(i,N-K+1)
	ans = max(ans, max(acc[i+K] - acc[i], 0LL) + pos[N]-pos[i+K]+pos[i]);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define IOS {ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
#define endl "\n"
#define int long long int
#define f(i, a, b) for(int i=a; i<b; i++)
#define fb(i, a, b) for(int i=a; i>=b; i--)
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define S(x) (int) x.size()
#define LB lower_bound
#define UB upper_bound
#define fp(x, y) fixed<<setprecision(y)<<x
#define M 100005
#define mod 1000000007
#define PI 3.141592653589793238462643383279502884
using namespace std;

void solve()
{
	int n;
	int m = 1000000000000000000;
	cin>>n;
	int a[n], x = 1;
	cout<<fixed<<setprecision(0);
	f(i, 0, n) cin>>a[i];
	f(i, 0, n) if(a[i] == 0) {cout<<"0"; return;}
	f(i, 0, n)
	{
		if(m/x >= a[i])
		{
			x = x*a[i];
		}
		else
		{
			cout<<"-1\n";
			return;
		}
	}
	cout<<x;
}

int32_t main()
{
    IOS
    int t = 1;
    // cin>>t;
    f(tno, 1, t+1)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 4420
package main

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

func solve(io *io) {
	a := io.NextInt()
	b := io.NextInt()
	if a*b%2 == 0 {
		io.Println("No")
	} else {
		io.Println("Yes")
	}
}

func main() {
	io := newIo()
	defer io.Flush()
	solve(io)
}

type io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func newIo() *io {
	return &io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func (io *io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func intMin(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func intMax(a, b int) int {
	if a > b {
		return a
	}
	return b
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include<functional>
#include<ios>
#include<iomanip>
//#include <boost/multiprecision/cpp_int.hpp>

//namespace mp = boost::multiprecision;
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
//using Bint = mp::cpp_int;


int main()
{
	int H,W,K,ns=1;
	vector<vector<int>>res;
	cin>>H>>W>>K;
	for(int i=0;i<H;i++)
	{
		string S;
		cin>>S;
		int nns=-1;
		vector<int>row;
		for(int j=0;j<W;j++)
		{
			if(S[j]=='#')
			{
				nns=ns++;
			}
			row.push_back(nns);
		}
		if(i!=0&&nns==-1)
		{
			res.push_back(res[i-1]);
		}
		else
		{
			res.push_back(row);
		}
	}
	for(int i=H-1;i>=0;i--)
	{
		int bp=-1;
		for(int j=res[i].size()-1;j>=0;j--)
		{
			if(res[i][j]==-1)
			{
				res[i][j]=bp;
			}
			else
			{
				bp=res[i][j];
			}
		}
		if(bp==-1)
		{
			res[i]=res[i+1];
		}
	}
	for(int i=0;i<H;i++)
		for(int j=0;j<W;j++)
		{
			cout<<res[i][j]<<(j==W-1?'\n':' ');
		}
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int,int> PII;

struct UnionFind{
  VI par;
  UnionFind(int N):par(N){
    rep(i,N) par[i]=i;
  }
  int root(int x){
    if(par[x]==x) return x;
    return par[x]=root(par[x]);
  }
  void unite(int x, int y){
    int rx=root(x);
    int ry=root(y);
    if(rx==ry) return;
    par[rx]=ry;
  }
  bool same(int x, int y){
    int rx=root(x);
    int ry=root(y);
    return rx==ry;
  }
};

int main(){
  int H,W;
  cin>>H>>W;
  vector<string> S(H);
  rep(i,H) cin>>S[i];
  UnionFind tree(H*W+1);
  rep(i,H) rep(j,W-1) if(S[i][j]!=S[i][j+1]) tree.unite(i*W+j,i*W+j+1);
  rep(i,H-1) rep(j,W) if(S[i][j]!=S[i+1][j]) tree.unite(i*W+j,(i+1)*W+j);
  vector<ll> N(H*W);
  vector<ll> B(H*W);
  rep(i,H) rep(j,W){
    N[tree.root(i*W+j)]++;
    if(S[i][j]=='#') B[tree.root(i*W+j)]++;
  }
  ll ans=0;
  rep(i,H*W) ans+=B[i]*(N[i]-B[i]);
  cout<<ans<<endl;
}

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

using namespace std;

using ll = long long;

// const int n = 50;
// vector<vector<int>> win(2 * n + 1, vector<int>(2 * n + 1, -1));
// bool Dfs(int a, int b) {
//     if (win[a][b] != -1) return win[a][b];

//     int &res = win[a][b] = 0;
//     for (int i = 1; 2 * i <= a; ++i) {
//         if (!Dfs(a - 2 * i, b + i)) {
//             res = true;
//             break;
//         }
//     }

//     if (res) return true;

//     for (int i = 1; 2 * i <= b; ++i) {
//         if (!Dfs(a + i, b - 2 * i)) {
//             res = true;
//             break;
//         }
//     }

//     return res;
// }

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

    // win[0][0] = win[1][0] = win[0][1] = win[1][1] = 0;

    // for (int a = 0; a <= n; ++a) {
    //     for (int b = 0; b <= n; ++b) {
    //         cout << "(" << a << ", " << b << ") = " << Dfs(a, b) << endl;
    //         // for (int i = 1; 2 * i <= a; ++i)
    //         //     cout << "(" << a - 2 * i << ", " << b + i << ") = " << Dfs(a - 2 * i, b + i) << endl;;
    //         // for (int i = 1; 2 * i <= b; ++i)
    //         //     cout << "(" << a + i << ", " << b - 2 * i << ") = " << Dfs(a + i, b - 2 * i) << endl;;
    //     }
    //     cout << endl;
    // }

    ll a, b;
    cin >> a >> b;
    if (b == a || b == a - 1 || b == a + 1) cout << "Brown\n";
    else cout << "Alice\n";

    return 0;
}


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

using namespace std;

int main()
{
	stack<int> hako;
	int temp[100];
	int input[100];
	int t, i = 0, k = 0;
	
	
	while(cin>>t){
		input[i] = t;
		i++;
	}
	
	/*
	while(1){
		cin >> t;
		if( t == -1){
			break;
		}
		input[i] = t;
		i++;
	}
	*/
	for(int j = 0; j < i; j++){
		if(input[j] == 0){
			temp[k] = hako.top();
			hako.pop();
			k++;
		}
		else{
			hako.push(input[j]);
		}
	}
	
	for(int j = 0; j < k; j++){
		cout << temp[j] << endl;
	}
	
}
			

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

int main() {
  string S, T, U;
  int A, B;
  cin >> S >> T;
  cin >> A >> B;
  cin >> U;

  if (U == S) {
    A--;
  } else {
    B--;
  }

  cout << A << " " << B << endl;
      
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string.h>
#define P pair<double,double>
using namespace std;
double EPS=1e-10;
double add(double a, double b)
{
	if(abs(a+b)<EPS*(abs(a)+abs(b))) return 0;
	return a+b;
}
bool cmp_x(const P& p, const P& q)
{
	if(p.first !=q.first) return p.first<q.first;
	return p.second>q.second;
}
P p[100];
vector<P> v;
vector<int> num;
int n;
bool used[100];
void make_convex(int l,int r)
{
	for(int i=l ;(r>l ? i<r : i>=r);(r>l ? i++ : i--))
	{
		if(used[i]) continue;
		for(bool loop=true;loop; )
		{
			loop=false;
			if(v.size()<2) {v.push_back(p[i]),num.push_back(i),used[i]=true; continue;}
			if(v.size()==2)
			{
				double vx[2],vy[2];
				vx[0]=v[1].first-v[0].first;
				vy[0]=v[1].second-v[0].second;
				vx[1]=p[i].first-v[1].first;
				vy[1]=p[i].second-v[1].second;
				if(add(vx[0]*vy[1],-vx[1]*vy[0])<=0) v.push_back(p[i]),num.push_back(i),used[i]=true;
				else used[num[1]]=false,num.pop_back(),v.pop_back(),loop=true;
				continue;
			}
			double vx[3],vy[3]; int len=v.size();
			vx[0]=v[len-2].first-v[len-3].first;
			vy[0]=v[len-2].second-v[len-3].second;
			vx[1]=v[len-1].first-v[len-2].first;
			vy[1]=v[len-1].second-v[len-2].second;
			vx[2]=p[i].first-v[len-1].first;
			vy[2]=p[i].second-v[len-1].second;
			if(add(vx[1]*vy[2],-vx[2]*vy[1])<=0) v.push_back(p[i]),num.push_back(i),used[i]=true;
			else used[num[len-1]]=false,num.pop_back(),v.pop_back(),loop=true;
		}
	}
}
int main()
{
	while(1)
	{
		cin >> n; if(!n) break;
		v.clear(); num.clear(); memset(used,false,sizeof(used));
		for(int i=0;i<n;i++) scanf("%lf,%lf",&p[i].first,&p[i].second);
		sort(p,p+n,cmp_x);
		//pはxの昇順、yの降順。時計回りで見ること
		make_convex(0,n);
		int tmp=v.size(); v.clear(),num.clear(); memset(used,false,sizeof(used));
		make_convex(n-1,0);
		cout << n-(tmp+v.size()-2) << '\n' ;
	}
}

Measured memory_bytes: 1292
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

# input
inputs = []
lc = 0
nn = 0
scores = []
edge = []
while l = $stdin.gets do
  if lc == 0
    nn = l.chomp.to_i
    nn.times do 
      edge << []
    end
  elsif lc < nn
    tmp_edge = l.chomp.split(" ").map(&:to_i)
    edge[tmp_edge[0] - 1] << tmp_edge[1] - 1
    edge[tmp_edge[1] - 1] << tmp_edge[0] - 1
  else # lc == nn
    scores = l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end
scores = scores.sort.reverse

pd nn
edge.each do |x_i|
  pd x_i
end
pd scores
pd ans_val = scores[1..-1].inject(:+)

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

# body
if $debugFlag
end

ans = []
queue = [0]
hh = {}
while queue != []
  print "queue: " if $debugFlag
  pd queue
  node = queue.shift
  ans[node] = scores.shift
  hh[node] = true
  for i in 0..edge[node].size-1
    queue.push(edge[node][i]) if hh[edge[node][i]] == nil
  end
end
pd ans

str = ""
ans.each do |a_i|
  str += "#{a_i} "
end

puts ans_val
puts str.chomp


Measured memory_bytes: 61860
n = int(input())
m = [[0] * (n + 1) for _ in range(n + 1)]
z = [0] * (n + 1)
for i in range(n):
    z[i], z[i + 1] = map(int, input().split())
j = 0
for l in range(2, n + 1):
    for i in range(1, n - l + 2):
        j = i + l - 1
        m[i][j] = float("inf")
        for k in range(i, j):
            m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + z[i - 1] * z[k] * z[j])
print(m[1][n])

Measured memory_bytes: 7868
#include<iostream>
#include<math.h>
#include<cstdio>
using namespace std;
int main(){
	while(1){
		long long a,b;
		cin>>a>>b;
		long long c=a*b;
		long temp;
		if(a<b){temp=a;a=b;b=temp;}
		if(cin.eof()) {break;}
		long q,r;
		while(a%b!=0){
			q=(long long)a/b;		
			r=(long long)a%b;
			a=b;
			b=r;
		}
		cout<<b<<" "<<c/b<<endl;		
	}
	return 0;	
}

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

int n;
string s;
int s_cnt[26];
int ans = 0;

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

  for(int i = 0; i< n; i+=2){
    s_cnt[s[i] - 'a']++;
  }

  for(int i = 1; i <= 9; i++){
    int a = 0;
    for(int j = 0; j < 26; j++) {
      if(i == s_cnt[j]){
	a++;
      }      
    }

    if(i == 1) {
      ans += 2 * a;
    }else{
      if(a == 1) ans += 4;
      if(a >= 2) ans += 2*a +4;
    }
  }
  
  ans--;
  
  cout << ans << endl;
}

Measured memory_bytes: 1208
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
const int INF=1e+9;
const ll INFLL=1e+17;
int N;
vi solve(){
  vi res;
  if(N==3){
    res.push_back(2);
    res.push_back(3);
    res.push_back(25);
    return res;
  }
  res.push_back(2);
  res.push_back(4);
  res.push_back(3);
  res.push_back(9);
  int j=1,s=4;
  while(s<N-1&&j<5000){
    res.push_back(6*j+2);
    res.push_back(6*j+4);
    j++;
    s+=2;
  }
  if(j!=5000){
    if(N%2==1){
      res.push_back(6);
      return res;
    }
    else{
      return res;
    }
  }
  j=1;
  while(s<N-1&&j<2500){
    res.push_back(12*j+3);
    res.push_back(12*j+9);
    j++;
    s+=2;
  }
  if(j!=2500){
    if(N%2==1){
      res.push_back(6);
      return res;
    }
    else{
      return res;
    }
  }
  j=1;
  while(s<N){
    res.push_back(6*j);
    j++;
    s++;
  }
  return res;
}
int main(){
  cin>>N;
  vi res=solve();
  int rs=res.size();
  rep(i,rs) std::cout<<res[i]<<" ";
  std::cout<<"\n";
  return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		boolean b = false;
		for(int i = 1; i < 10; i++) {
			if(N % i == 0 && N / i < 10) {
				b = true;
			}
		}
		if(b) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		sc.close();
	}
}


Measured memory_bytes: 23760
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define REP1(i,n) for(int i=1; i<=(int)(n); i++)
#define SORT(v) sort(v.begin(), v.end())
#define REVERSE(v)  reverse(v.begin(), v.end())
using namespace std;

int main() {
  int H,W; scanf("%d%d",&H,&W);
  // cin>>H>>W;
  int a[H+2][W+2];
  int N = 0;
  int p[250010],q[250010],r[250010],s[250010];
  REP1(i,H) {
    REP1(j,W) {
      scanf("%d",&a[i][j]);
      // cin>>a[i][j];
    }
  }

  REP1(i,H-1) {
    REP1(j,W) {
      if(a[i][j] % 2 == 1) {
        N++;
        a[i+1][j]++;
        p[N]=i;
        q[N]=j;
        r[N]=i+1;
        s[N]=j;
        // cout<<a[i]<<" "<<a[j]<<" "<<a[i+1]<<" "<<a[j]<<endl;
      }
    }
  }

  REP1(j,W-1) {
    if(a[H][j] % 2 == 1) {
      N++;
      a[H][j+1]++;
      p[N]=H;
      q[N]=j;
      r[N]=H;
      s[N]=j+1;
      // cout<<a[H]<<" "<<a[j]<<" "<<a[H]<<" "<<a[j+1]<<endl;
    }
  }
	
  printf("%d\n",N);
  //cout<<N<<endl;
  REP1(i,N) {
    printf("%d %d %d %d\n",p[i],q[i],r[i],s[i]);
    // cout<<p[i]<<" "<<q[i]<<" "<<r[i]<<" "<<s[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 6144
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
using namespace std;
int n,m,i,j,g[505][505],a[505],b[505],l,r;
int f(int x,int y)
{
	int i;
	for(i=0;;i++){
		if(((x>>i)&1)!=((y>>i)&1)) return i+1;
	}
}
int main()
{
	scanf("%d",&n);
	fz1(i,n-1){
		fz(j,i+1,n){
			printf("%d ",f(i,j));
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 512
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;
using TP = tuple<int, int, int>;

// Binary Indexed Tree (Fenwick Tree)
// https://youtu.be/lyHk98daDJo?t=7960
template<typename T>
struct BIT {
    int n;
    vector<T> d;
    BIT(int n=0):n(n),d(n+1) {}
    void add(int i, T x=1) {
        for (i++; i <= n; i += i&-i) {
            d[i] += x;
        }
    }
    T sum(int i) {
        T x = 0;
        for (i++; i; i -= i&-i) {
            x += d[i];
        }
        return x;
    }
    T sum(int l, int r) {
        return sum(r-1) - sum(l-1);
    }
};

const ll INF = 1e18;
void Main(){
    ll n, d, a; cin >> n >> d >> a;
    vector<pair<ll, ll>> m(n);
    rep(i, n) cin >> m[i].fi >> m[i].se;
    sort(all(m));

    BIT<ll> bit(n);
    
    ll ans = 0;
    rep(i, n){
        ll l = m[i].fi;
        ll hp = m[i].se;
        hp -= bit.sum(i);
        if(hp <= 0) continue;
        ll cnt = (hp + a - 1) / a;
        ll damage = a * cnt;
        ll r = l + 2 * d;
        pair<ll, ll> R = {r, INF};
        ll ni = upper_bound(all(m), R) - m.begin();
        bit.add(i, damage);
        bit.add(ni, -damage);
        ans += cnt;
        // cout << i << ": " << l << ", " << r << ": " << ni << " " << cnt << endl;
    }
    
    cout << ans << endl;    
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

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

const int INF = 1000000000;

int main()
{
	while(true){
		int n, m;
		cin >> n >> m;

		if(n==0 && m==0)
			break;

		int C[100][100];
		int T[100][100];
		for(int i=0; i<m; i++){
			for(int j=0; j<m; j++){
				if(i==j){
					C[i][j] = T[i][j] = 0;
				}
				else{
					C[i][j] = T[i][j] = INF;
				}
			}
		}

		for(int i=0; i<n; i++){
			int a, b, c, t;
			cin >> a >> b >> c >> t;

			C[a-1][b-1] = C[b-1][a-1] = c;
			T[a-1][b-1] = T[b-1][a-1] = t;
		}

		/*int N,p,q,r;
		int d[100][100];
		cin >> N;
		for(int I=0;I<N;I++){
			cin >> p >> q >> r;
			if(r){
				for(int i=0;i<m;i++){
					for(int j=0;j<m;j++){
						d[i][j]=T[i][j];
					}
				}
			}else{
				for(int i=0;i<m;i++){
					for(int j=0;j<m;j++){
						d[i][j]=C[i][j];
					}
				}
			}
			for(int k=0;k<m;k++){
				for(int i=0;i<m;i++){
					for(int j=0;j<m;j++){
						if(d[i][j]>d[i][k]+d[k][j]){
							d[i][j]=d[i][k]+d[k][j];
						}
					}
				}
			} 
			cout << d[p-1][q-1] << endl;
		}*/
		
		int k,p,q,r;
		cin >> k;
		for(int I=0;I<k;I++){
			int d[m];
			bool u[m];
			cin >> p >> q >> r;
			for(int i=0;i<m;i++){
				d[i] = INF;
				u[i] = false;
			}
			d[p-1]=0;

			while(1){
				int v = -1;
				for(int i=0;i<m;i++){
					if(u[i])continue;
					if(v==-1||d[i]<d[v]){
						v = i;
					}
				}
				if(v==-1)break;
				u[v]=true;

				for(int i=0;i<m;i++){
					if(r){
						if(d[i]>d[v]+T[v][i]){
							d[i]=d[v]+T[v][i];
						}
					}else{
						if(d[i]>d[v]+C[v][i]){
							d[i]=d[v]+C[v][i];
						}
					}
				}
			}
		
			cout << d[q-1] << endl;
		}		
	}

	return 0;
}

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

int main(){
    string input;
    string symbol = "+*-/";
    while(getline(cin, input)){
        input += " ";
        stack<double> st;
        while(input.find_first_of(" ") != string::npos){
            string s = input.substr(0, input.find_first_of(" "));
            if(symbol.find(s) == string::npos){st.push(atoi(s.c_str()));}
            else {
                double n, m;
                n = st.top(); st.pop();
                m = st.top(); st.pop();
                if(s == "+") m += n;
                else if(s == "-") m -= n;
                else if(s == "*") m *= n;
                else if(s == "/") m /= n;

                st.push(m);
            }
            input = input.substr(input.find_first_of(" ")+1);
        }
        printf("%lf\n", st.top());
    }
}

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

int main(){

  int a=0;
  int b=0;
  
  cin>>a>>b;
  
  if(a%b==0)cout<<a/b;
  else cout<<a/b+1;
}

Measured memory_bytes: 256
fn main() {
	let text = {
		use std::io::Read;
		let mut s = String::new();
		std::io::stdin().read_to_string(&mut s).unwrap();
		s
	};
	let mut iter = text.split_whitespace();
	let a: i64 = iter.next().unwrap().parse().unwrap();
	let b: i64 = iter.next().unwrap().parse().unwrap();
	let mut c: i64 = iter.next().unwrap().parse().unwrap();
	let mut cnt: i64 = 0;
	let mut day: i64 = 0;
	while 0 < c {
		cnt += 1;
		day += 1;
		c -= a;
		if 7 <= day {
			day = 0;
			c -= b;
		}
	}
	println!("{}", cnt);
}



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

int main(){
	int h,w;
	cin >> h >> w;
	int a,b;
	cin >> a >> b;
	int ans[1005][1005];
	
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(i<b && j<a){
				ans[i][j] = 1;
			} else if (i < b && j >= a){
				ans[i][j] = 0;
			} else if (i >= b && j < a){
				ans[i][j] = 0;
			}else{
				ans[i][j] = 1;
			}
		}
	}
	
for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cout << ans[i][j];
		}
		cout << endl;
	}
    return 0;
}



Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }






int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    /*
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    */
    
    
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b + c >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
typedef long long ll;

int main() {
  int n;
  cin >> n;
  int ans =  ceil(n/2.0);
  cout << ans << endl;
}



Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	
		// 整数の入力(スペース改行関係なし)
		String s = sc.next();
      	String t = sc.next();
      	int count = 0;
      
      for(int i = 0; i< s.length();i++){
      	if(s.charAt(i)!=t.charAt(i)){
          count += 1;
        }
      }
		System.out.println(count);
    }
}

Measured memory_bytes: 41244
#!/usr/bin/env python3


n, m = list(map(int, input().split()))
h = list(map(int, input().split()))

best = [1 for i in range(n)]
for i in range(m):
    a, b = list(map(int, input().split()))
    if h[a-1] <= h[b-1]:
        best[a-1] = 0
    if h[b-1] <= h[a-1]:
        best[b-1] = 0

# print(best)
print(sum(best))


Measured memory_bytes: 20104
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#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;
  cin >> n;
  map<int,int> mp;
  rep(i,n){
    int x;
    cin >> x;
    mp[x]++;
  }
  int m;
  cin >> m;
  rep(i,m){
    cin >> n;
    if (mp[n] > 0){
      mp[n]--;
    }else{
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 12968
#include<stdio.h>
#include<string.h>

int main() {
    int K, i=0;
    char S[109];

    scanf("%d" "%s", &K, S);
    int n = strlen(S);

        if(n <= K) {
            printf("%s\n", S);
        }
        else {
            for(i=0; i<K; i++) {                
                printf("%c", S[i]);
            }
            printf("...");
        }
    return 0;
}

Measured memory_bytes: 1688
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <iomanip>
#include <vector>
#include <string>
#include <cstdio>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <set>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define ls x<<1
#define rs x<<1|1
#define fi first
#define se second
#define ll long long
#define pb push_back
#define mp make_pair
#define fun function
#define vi vector<int>
#define lowbit(x) x&(-x)
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
#define int long long
using namespace std;

const int INF = 0x3f3f3f3f;
const int N=1e6+10;

int cnt[N];

signed main() {
	IOS;
#ifdef xiaofan
	freopen("1.in","r",stdin);
	freopen("1.out","w",stdout);
#endif

	string s;
	int n,p,ans=0;
	cin>>n>>p>>s;
	if(p==2||p==5) {
		for(int i=0; i<n; i++)
			if((s[i]-'0')%p==0) ans+=i+1;
	} else {
		int t=1,sum=0;
		cnt[0]=1;
		for(int i=n-1; i>=0; i--) {
			sum=(sum+(s[i]-'0')*t)%p;
			ans+=cnt[sum];
			cnt[sum]++;
			t=t*10%p;
		}

	}

	cout<<ans<<endl;




	return 0;
}



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

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

int main() {
  int n,m;
  cin >> n >> m;
  vector<ll> v(n);
  rep(i,n) cin >> v[i];
  int c = min(n,m)+1;
  ll ans = -10000000000;
  for(int i = 0; i < c; i++) {
    for(int j = 0; j < c-i; j++) {
      //printf("i = %d, j = %d start!\n",i,j);
      vector<ll> a(0);
      for(int k = 0; k < i; k++) {
        a.push_back(v[k]);
      }
      for(int k = 0; k < j; k++) {
        a.push_back(v[n-1-k]);
      }
      sort(a.begin(),a.end());
      ll value = 0;
      for(int k = 0; k < i+j; k++) {
        //printf("%lld ", a[k]);
        if (k < m-i-j && a[k] < 0) continue;
        value += a[k];
      }
      //printf("\n");
      ans = max(ans,value);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3528
#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int n,m; while(cin>>n>>m,n){
		int l[n][n],p[4][m][m];
		rep(i,n)rep(j,n)cin>>l[i][j];
		rep(i,m)rep(j,m)cin>>p[0][i][j];
		rep(i,3)rep(y,m)rep(x,m)p[i+1][m-1-x][y]=p[i][y][x];
		int ay=n,ax=n;
		rep(d,4)rep(y,n-m+1)rep(x,n-m+1){
			bool sc=1,f=0; int ty=n,tx=n;
			rep(i,m)rep(j,m){
				if(!sc||p[d][i][j]==-1)continue;
				if(!f)ty=y+i,tx=x+j,f=1;
				if(p[d][i][j]!=l[y+i][x+j])sc=0;
			}
			if(sc&&(ty<ay||ty==ay&&tx<ax))ay=ty,ax=tx;
		}
		if(ay<n&&ax<n)cout<<ax+1<<" "<<ay+1<<endl;
		else cout<<"NA"<<endl;
	}
	return 0;
}

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

int main(){
  int N;
  cin>>N;
  vector<int> length(2*N);
  for(int i=0;i<2*N;i++)
    cin>>length.at(i);
  sort(length.begin(),length.end());
  int count=0;
  for(int i=0;i<N;i++)
    count+=length.at(2*i);
  cout<<count<<endl;
}

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

int main()
{
    long long int n,k,d,m,s,f;
    cin>>n>>k;
    d=n/k;
    m=n-(k*d);
    s=abs(k-m);
   f=min(m,s);
   cout<<f<<"\n";
   return 0;
}

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

int main() {
  int N;
  bool flag = false;
  cin >> N;
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    if (S == "Y") {
      flag = true;
    }
  }
  if (flag) {
    cout << "Four" << endl;
  }
  else {
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  char a,b;
  cin>>a>>b;
  if(a=='H'){
    if(b=='H') cout<<"H"<<endl;
    if(b=='D') cout<<"D"<<endl;
  }else{
    if(b=='H') cout<<"D"<<endl;
    if(b=='D') cout<<"H"<<endl;
  }
  return 0;
}


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

int main(){
  int n;
  string s, t;
  cin >> n;
  cin >> s >> t;
  rep(i, n) cout << s[i] << t[i];
  return 0;
}


Measured memory_bytes: 3592
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define REPS(i,n) for(int i=1;i<=(n);i++)
#define RREPS(i,n) for(int i=(n);i>0;i--)
#define mp make_pair
#define pb(a) push_back(a)
typedef long long ll;
#define MAX_N 100000
int cnt[MAX_N];
bool red[MAX_N];

int main(){
  int N,M;
  cin >> N >> M;
  REP(i,N){
    cnt[i] = 1;
  }
  red[0] = true;
  REP(i,M){
    int x,y;
    cin >> x >> y;
    x--;y--;
    if(red[x]) red[y] = true;
    if(cnt[x] == 1) red[x] = false;
    cnt[x]--;
    cnt[y]++;
  }
  int ans = 0;
  REP(i,N){
    if(red[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;
const int N = 1e6 + 10;


int n , m , q , mod , g , z;


int id[N][2][3] , icnt , par[N * 6] , u[N],v[N],c[N];
int can[2][1000010];

int find(int x){
	if (par[x] != x){
		return par[x] = find(par[x]);
	}
	return par[x];
}
void merge(int x,int y){
	x = find(x) , y = find(y);
	if (x != y){
		par[x] = y;
	}
}
int main(){
	scanf("%d%d%d%d",&n,&m,&q,&mod);
	for (int i = 1;i <= m;i++){
		scanf("%d%d%d",&u[i],&v[i],&c[i]);
		g=__gcd(g,abs(c[i]-c[1]));
	}
	if (!g) g = mod;
	mod = __gcd(mod , 3 * g);
	z = c[1] % g;
	
	for (int i = 1;i <= n;i++)
	for (int j = 0;j < 2;j++)
	for (int k = 0;k < 3;k++)
	id[i][j][k] = ++icnt;
	
	
	for (int i = 1;i <= icnt;i++) par[i] = i;
	for (int i = 1;i <= m;i++){
		int w=(c[i]-z)/g;
		for (int p = 0;p < 2;p++)
		for (int q = 0;q < 3;q++){
			merge(id[u[i]][p][q],id[v[i]][1^p][(2*q+w)%3]);
			merge(id[v[i]][p][q],id[u[i]][1^p][(2*q+w)%3]);
		}
	}
	
	int mul = z;
	for (int i = 0;i <= (mod << 1);i++){
		can[i & 1][mul] = 1;
		mul = 2 * mul % mod;
	}
	
	while (q--){
		int s , t , r;
		scanf("%d%d%d",&s,&t,&r);
		int ret = 0;
		for(int p = 0;p < 2;p++) 
		for(int q = 0;q < 3;q++) 
		if ( find(id[t][0][0]) == find(id[s][p][q]) ){ 
			ret |= can[p][(r+z+(3-q)*g)%mod];
			if (ret) break;
		}
		puts(ret?"YES":"NO");
	}
	return 0;
}

Measured memory_bytes: 20864
#include<stdio.h>

int main(void)
{
	int K,S,x,y,n,N=0;
	
	scanf("%d %d",&K,&S);
	
	for(x=0;x<=K;x++)
	{
		for(y=0;y<=K;y++)
		{
			n=S-x-y;
			if(0<=n&&n<=K) N=N+1;
		}
	}
	
	printf("%d",N);
	
	return 0;
}

Measured memory_bytes: 128
import math
a,b,h,m = map(int, input().split())

a_deg = 30*h + 0.5 * m
b_deg = 6*m
rad = math.radians(abs(a_deg - b_deg))
c = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(rad))
print(c)

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

int main() {
 long int as=0,bs=0,cs=0,ds=0;
 cin >> as;
 long int zs[as];
 for(long int i=0;i<as;i++){
   cin >> zs[i];
   if(i==0){
     bs = zs[i];
     cs = zs[i];
   }
   
     if(zs[i]<bs){
       bs = zs[i];
     }
     if(zs[i]>cs){
       cs = zs[i];
     }
  
   ds = ds + zs[i];
 }
  cout << bs << ' ' << cs << ' ' << ds << endl;

}



Measured memory_bytes: 3156
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;

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

	int n, k;
	cin >> n >> k;
	vi a(n);
	rep(i, n) cin >> a[i];

	int ans = 0;
	rep(i, n) {
		if (a[i] > k - a[i]) {
			ans += 2 * (k - a[i]);
		}
		else {
			ans += 2 * a[i];
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n,t,a;
    cin>>n;
    cin>>t>>a;
    vector<int>h(n);
    for(int i=0;i<n;i++)
    {
        cin>>h[i];
    }
    float result;
    int index=0;
    bool inside=true;
    for(int i=0;i<n;i++)
    {
        float temp;
        temp=t*1.0-h[i]*0.006;
        if(inside||abs(temp-a)<abs(result-a)){
            result=temp;
            index=i+1;
            inside=false;
        }
    }
    cout<<index;
}

Measured memory_bytes: 3616
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N, M = map(int, input().split())
    XY = [tuple(map(int, input().split())) for _ in [0] * M]

    box = [1] * (N + 1)
    red = [0] * (N + 1)
    box[0], red[1] = 0, 1
    for x, y in XY:
        box[x] -= 1
        box[y] += 1
        if red[x]:
            red[y] = 1
        if not box[x]:
            red[x] = 0
    print(sum(red))


main()


Measured memory_bytes: 23888
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            solve(in);
        }
    }

    private static void solve(Scanner in) {
        int N = in.nextInt();
        while (N-- > 0) {
            int a = in.nextInt(), b = in.nextInt(), c = in.nextInt();
            int A = a * a, B = b * b, C = c * c;
            boolean isRight;
            if (A > B && A > C) {
                isRight = A == B + C;
            } else if (B > A && B > C) {
                isRight = B == A + C;
            } else {
                isRight = C == A + B;
            }
            System.out.println(isRight ? "YES" : "NO");
        }
    }
}

Measured memory_bytes: 33492
n = int(input())
info = [list(map(int,input().split())) for i in range(n-1)]

for i in range(n):
  ans = 0
  for j in range(i,n-1):
    if ans - info[j][1] <= 0:
      ans = info[j][0] + info[j][1]
    else:
      if (ans - info[j][1]) % info[j][2] == 0:
        ans = ans + info[j][0]
      else:
        ans = ans + (info[j][2] - (ans - info[j][1]) % info[j][2]) + info[j][0]
  print(ans)

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

	private static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int n = sc.nextInt(), m = sc.nextInt();
		String[] a = new String[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.next();
		}
		String[] b = new String[m];
		for (int i = 0; i < m; i++) {
			b[i] = sc.next();
		}
		for (int i = 0; i < n - m + 1; i++) {
			for (int j = 0; j < n - m + 1; j++) {
				boolean ans = true;
				for (int k = 0; k < m; k++) {
					for (int l = 0; l < m; l++) {
						if (a[i + k].charAt(j + l) != b[k].charAt(l)) {
							ans = false;
						}
					}
				}
				if (ans) {
					System.out.println("Yes");
					return;
				}
			}
		}
		System.out.println("No");
	}
}

Measured memory_bytes: 22228