akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
string s, t;
cin >> s >> t;
int a, b;
cin >> a >> b;
string u;
cin >> u;
if(s == u) a--;
else b--;
cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
b = list(map(int, input().split()))
ans = [-1] * n
ans[0]=b[0]
ans[-1]=b[-1]
for i,B in enumerate(b):
    if i==n-2:
        break
    next_b=b[i+1]
    ans[i+1]=min(B, next_b)
#    print(ans)
    
print(sum(ans))

Measured memory_bytes: 3064
#include <iostream>
 #include <math.h>
 #include <iomanip>

 int main(){
 int R;
 std::cin>>R;
 const double pi=acos(-1.0);
 double answer=2*R*pi;
 std::cout<<std::setprecision(20)<<std::fixed<<answer<<std::endl;
 return 0;
 }


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

ll dp[1000000];

ll fib(ll n){
    if(dp[n] >= 0) return dp[n];

    if(n == 0) dp[n] = 0;
    else if(n == 1) dp[n] = 1;
    else dp[n] = fib(n-1) + fib(n-2);
    return dp[n];
}

int main(){
    ll n; cin >> n;
    memset(dp, -1, 1000000*sizeof(ll));

    cout << fib(n+1) << endl;
    return 0;
}


Measured memory_bytes: 10916
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
void *wmem;
char memarr[96000000];
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = my_getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = my_getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void rd(string &x){
  char *buf = (char *)wmem;
  rd(buf);
  x = buf;
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    my_putchar_unlocked(c[i]);
  }
}
string S;
int main(){
  wmem = memarr;
  rd(S);
  if(S=="ABC"){
    wt_L("ARC");
    wt_L('\n');
  }
  else{
    wt_L("ABC");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20200419-1

// --- original code ---
// string S;
// {
//   rd(S);
//   wt(if[S=="ABC", "ARC", "ABC"]);
// }


Measured memory_bytes: 3648
program speedrun
   implicit none
   integer::N
   integer(16),allocatable,dimension(:)::A

   integer::i
   integer(16),allocatable,dimension(:)::SUMA
   integer(16),allocatable,dimension(:,:)::DP
   read*,N
   allocate(A(N))
   read*,A
   allocate(SUMA(0:N))
   SUMA(0)=0
   do i=1,N
      SUMA(i)=SUMA(i-1)+A(i)
   end do
   allocate(DP(N,N))
   DP=-1
   do i=1,N
      DP(i,i)=0
   end do
   print"(i0)",calcDP(1,N)
contains
integer(16) recursive function calcdp(l,r)result(res)
   integer,intent(in)::l,r
   integer::i
   if(DP(l,r)/=-1)then
      res=dp(l,r)
      return
   endif

   res=huge(res)
   do i=l,r-1
      res= min(res,calcdp(l,i)+calcdp(i+1,r)+SUMA(R)-SUMA(L-1))
   end do
   dp(l,r)=res
end function

end program speedrun

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    int V[N], C[N];
    for (int i = 0; i < N; i++)
    {
        cin >> V[i];
    }
    for (int i = 0; i < N; i++)
    {
        cin >> C[i];
    }
    int ans = 0;
    for (int bit = 0; bit < (1 << N); bit++)
    {
        int XY = 0;
        for (int i = 0; i < N; i++)
        {
            if (bit & (1 << i))
            {
                XY += V[i] - C[i];
            }
        }
        ans = max(ans, XY);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 9999999999;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define pb push_back
#define f first
#define s second
#define pi 3.141592653589793238
using namespace std;
ll dp[100010];
int main()
{
	std::ios::sync_with_stdio(false);
	
	ll n,m;
	cin >> n >> m;
	
	set<ll> se;
	for(int i = 1;i<=m;i++)
	{
		ll x;
		cin >> x;
		se.insert(x);
	}	
	dp[1] = 1;
	dp[2] = 2;
	if(se.find(1)!=se.end())
	{
		dp[1] = 0;
		dp[2] = 1;
	}
	if(se.find(2)!=se.end())
	{
		dp[2] = 0;
	}

	for(int i = 3;i<=n;i++)
	{
		if(se.find(i)==se.end())
		dp[i] = (dp[i-1] % mod + dp[i-2]%mod)%mod;
	}
	cout << dp[n]%mod << endl;
	return 0;
}



Measured memory_bytes: 4992
let split c s = (
    let res = ref [] in
    let i = ref 0 in
    let n = String.length s in
    while !i < n do
      let j = !i in
      while !i < n && s.[!i] <> c do i := !i + 1 done;
      res := String.sub s j (!i - j) :: !res;
      i := !i + 1;
    done;
    List.rev !res
  );;

let rec range a b = if a > b then [] else a :: range (a + 1) b;;

let read_ints () = read_line () |> split ' ' |> List.map int_of_string;;
let inf = 1000000000;;

let [n; l] = read_ints ();;
let a = range 0 (n - 1) |> List.map (fun i -> l + i);;
let s = List.fold_left ( + ) 0 a;;
let ans = List.fold_left (fun x y -> min x (abs y, s - y)) (inf, inf) a;;
print_int (snd ans);;
print_newline ();;


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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if((a==5 && b==5) || (a==5 && c==5) || (b==5 && c==5))
    {
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.out


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    int a,b,c;
    cin>>a>>b>>c;
    cout<<min(a*b,c)<<endl;
    
//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#135c
N = int(input())
list_A = list(map(int, input().split()))
list_B = list(map(int, input().split()))
 
#print("#################################################")
 
ans = 0
remaining_power = 0
 
if N>1:
    for i in range(N-1,-1,-1):
        #print(i,"… RP:",remaining_power,",A:",list_A[i+1],",B:",list_B[i])
 
        if remaining_power>list_A[i+1]:
            #余力のみで倒せる
            remaining_power=list_B[i]
            ans += list_A[i+1]
            #print("margin")
        elif remaining_power + list_B[i] > list_A[i+1]:
            #余力と勇者で倒せる
            remaining_power = list_B[i] - (list_A[i+1] - remaining_power)
            ans += list_A[i+1]
            #print("OK")
        else:
            #余力と勇者でも倒せない
            ans += remaining_power + list_B[i]
            remaining_power = 0
            #print("No")
else:
    remaining_power = list_B[0] 
            
if remaining_power > list_A[0]:
    ans += list_A[0]
else:
    ans += remaining_power
        
print(ans)

Measured memory_bytes: 18752
#include<stdio.h>
int main(){
  int n,m,i,j,p,np,d[100010];
  char s[100010];
  scanf("%d %d %s",&n,&m,s);
  for(i=0;i<n;i++)d[i]=1e9;
  d[n]=0;
  p=np=n;
  while(p){
    for(i=1;i<=m;i++){
      if(p-i<0)break;
      if(s[p-i]=='0'){
	d[p-i]=d[p]+1;
	np=p-i;
      }
    }
    if(np==p){
      printf("-1\n");
      return 0;
    }
    p=np;
  }
  //for(i=0;i<n;i++)printf("%d ",d[i]);printf("\n");
  while(p!=n){
    if(p)printf(" ");
    for(i=1;i<=m;i++){
      if(d[p]==d[p+i]+1)break;
    }
    printf("%d",i);
    p+=i;
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 896
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<map>
#include<vector>
#include<string>
#define ll long long
#define For(i,x,y)  for(ll i=x;i<=y;++i)
#define FOr(i,x,y)  for(ll i=x;i>=y;--i)
using namespace std;
inline ll read(){   ll x=0,f=1;char ch=getchar();   while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}  while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}  return x*f; } 
inline void write(ll x){    if (x<0) putchar('-'),x=-x; if (x>=10) write(x/10);   putchar(x%10+'0');  } 
inline void writeln(ll x){ write(x);   puts("");   }
const ll N=400010;
ll n,a[N],b[N];
int main(){
	n=read();
	For(i,1,n)	a[i]=read();
	ll l=1,r=n,rev=1;
	FOr(i,n,1){
		if (rev)	b[l++]=a[i];
		else	b[r--]=a[i];
		rev^=1;
	}
	For(i,1,n)	printf("%lld ",b[i]);
}

Measured memory_bytes: 7808
N = int(input())
S = list(map(int,input().split()))
s = sum(S)
S1 = 0
for i in range(N):
  S1 += S[i]
  S2 = s - S1
  if S1>=S2:
    if S1-S2<S2-S1+S[i]*2:
      print(S1-S2)
    else:
      print(S2-S1+S[i]*2)
    break

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Runtime.Remoting.Contexts;
using System.Security.Cryptography.X509Certificates;

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;
        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }
            var res = line[index];
            index++;
            return res;
        }
        public int NextInt()
        {
            return int.Parse(Next());
        }
        public long NextLong()
        {
            return long.Parse(Next());
        }
        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }
        public int[] IntArray()
        {
            var array = Array();
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }
        public long[] LongArray()
        {
            var array = Array();
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }
    }

    struct A
    {
        public int Value, Index;

        public A(int v, int i)
        {
            Value = v;
            Index = i;
        }
    }

    class Program
    {
        private int N;
        private int[] A;
        private void Scan()
        {
            var sc = new Scanner();
            N = sc.NextInt();
            A = sc.IntArray();
        }

        public void Solve()
        {
            Scan();
            Array.Sort(A);
            int b = A[N - 1];

            double min = double.MaxValue;
            int ans = -1;

            for (int i = 0; i < N - 1; i++)
            {
                if (min > Math.Abs((double) b / 2 - A[i]))
                {
                    ans = A[i];
                    min = Math.Abs((double) b / 2 - A[i]);
                }
            }
            Console.WriteLine($"{b} {ans}");
        }


        static void Main(string[] args)
        {
            new Program().Solve();
        }
    }
}

Measured memory_bytes: 20448
package main

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

func main() {
	t := nextIntArray()
	_, k := t[0], t[1]
	l := nextIntArray()
	sort.Sort(sort.Reverse(sort.IntSlice(l)))
	var amount int
	for i := 0; i < k; i++ {
		amount += l[i]
	}
	fmt.Println(amount)
}

const size = 1000000

var reader = bufio.NewReaderSize(os.Stdin, size)

func nextLine() string {
	var line, buffer []byte
	isPrefix := true
	var err error
	for isPrefix {
		line, isPrefix, err = reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
	}
	return string(buffer)
}
func nextStringArray() []string {
	return strings.Split(nextLine(), " ")
}
func nextInt() int {
	n, _ := strconv.Atoi(nextLine())
	return n
}
func nextIntArray() []int {
	s := strings.Split(nextLine(), " ")
	n := len(s)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i], _ = strconv.Atoi(s[i])
	}
	return a
}

func min(i, j int) int {
	if i > j {
		return j
	}
	return i
}


Measured memory_bytes: 640
//
//AtCoder Grand Contest 034
//A
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>
#include <bitset>
#include <numeric>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

const double PI = 3.14159265358979323846;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    int n,a,b,c,d;
    cin >> n >> a >> b >> c >> d;
    a--;b--;c--;d--;

    string s;
    cin >> s;

    REP(i,n-1){
        if (i<a) continue;
        if (i>d) continue;
        if (s[i]=='#' && s[i+1]=='#') {
            cout << "No" << endl;
            return 0;
        }
    }
    if (c<d){
        cout << "Yes" << endl;
        return 0;
    }else{
        REP(i,n-1){
            if (i<b) continue;
            if (i>d) continue;
            if (s[i-1]=='.' && s[i]=='.' && s[i+1]=='.') {
                cout << "Yes" << endl;
                return 0; 
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3756
N = int(input())
a = list(map(int, input().rstrip().split()))
even = [i for i in a if i%2 == 0]
count = 0
for i in even:
    c = 0
    while True:
        rem = i % 2
        i //= 2
        if rem == 1:
            break
        c += 1
    count += c
print(count)

Measured memory_bytes: 4148
#include<iostream>
using namespace std;
int main(){ 

  int  S,s,h,m,a;

  cin>>S;

  h=S/3600;

  a=S%3600;

  m=a/60;

  s=a%60;

  cout<<h<<":"<<m<<":"<<s<<endl;

     return 0;

}

Measured memory_bytes: 3092
def processes(inputs, disp)
  if inputs == [] then
    return disp
  end

  if inputs[0] == 'B'then
    processes(inputs[1, inputs.length - 1], disp[0, [disp.length - 1, 0].max])
  else
    processes(inputs[1, inputs.length - 1], disp + inputs[0])
  end
  
end

puts processes(gets.chomp.split(''), '')


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

int main(){
	int a[5];
	string ans;
	for (int i=0; i < 5; i++){
		cin >> a[i];
		}
	int k = 0;
	cin>>k;
	for (int i=0; i < 5; i++){
		for (int j=0; j<5; j++){
			if(a[i]-a[j] > k) {
				ans =  ":(" ;
				break;
				}
			else
			{
				ans = "Yay!";
			}
		}
		}
		
	cout << ans << endl;
	return 0;
	}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define pll pair <ll, ll>
#define mp make_pair
#define pyshnapyshnakaa ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
// #pragma optimize("TKACHENKO-GORYACHENKO")
#define x first
#define y second
#pragma GCC optimize("O3")
#define plll pair <pair <ll, ll>, ll>
#define pllll pair <pair <ll, ll>, pair <ll, ll> >
#define psl pair <string, ll>
#define all(a) a.begin(), a.end()
// #pragma comment(linker, "/stack:2000000000")
 
typedef long long ll;
 
typedef long double ld;
 
using namespace std;
 
const ll maxn = 1e6;
const ll inf = 1e9;

ll n, m, k, t;

ll A[maxn];

ll B[maxn];

int main() {
    ll q, w, e, a, b, c, d;
    string s;
    cin >> n >> m >> k;
    ll mna = inf, mnb = inf;
    for (q = 0; q < n; q++) {
        cin >> A[q];
        mna = min(mna, A[q]);
    }
    for (q = 0; q < m; q++) {
        cin >> B[q];
        mnb = min(mnb, B[q]);
    }
    ll ans = mna + mnb;
    for (q = 0; q < k; q++) {
        cin >> a >> b >> c;
        a--; b--;
        ll dans = A[a] + B[b] - c;
        ans = min(ans, dans);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

struct dat{
	int gr, mn;
	bool operator <(const dat &r) const{
		if (gr != r.gr) return gr < r.gr;
		return mn < r.mn;
	}
};

const int N = 33;

bool ok[N][N][N][N];
dat dp[N][N][N][N];
int v[N][N];
int sum[N][N];
int Min;

inline int rect(int t, int l, int b, int r){
	return sum[b][r] - sum[b][l] - sum[t][r] + sum[t][l];
}

dat rec(int t, int l, int b, int r){
	dat &res = dp[t][l][b][r];
	if (ok[t][l][b][r]) return res;
	ok[t][l][b][r] = true;
	res = {1, rect(t, l, b, r)};

	// tate
	for (int i = t + 1; i < b; ++i){
		if (rect(t, l, i, r) < Min) continue;
		if (rect(i, l, b, r) < Min) continue;
		dat r1 = rec(t, l, i, r);
		dat r2 = rec(i, l, b, r);
		dat tmp = { r1.gr + r2.gr, min(r1.mn, r2.mn) };
		res = max(res, tmp);
	}

	// yoko
	for (int j = l + 1; j < r; ++j){
		if (rect(t, l, b, j) < Min) continue;
		if (rect(t, j, b, r) < Min) continue;
		dat r1 = rec(t, l, b, j);
		dat r2 = rec(t, j, b, r);
		dat tmp = { r1.gr + r2.gr, min(r1.mn, r2.mn) };
		res = max(res, tmp);
	}

	return res;
}

int main(){
	int h, w, sup;
	while (cin >> h >> w >> sup, h){
		for (int i = 0; i < h; ++i)
			for (int j = 0; j < w; ++j)
				cin >> v[i][j];
		for (int i = 1; i <= h; ++i)
			for (int j = 1; j <= w; ++j)
				sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + v[i - 1][j - 1];

		Min = sum[h][w] - sup;
		memset(ok, 0, sizeof(ok));
		auto res = rec(0, 0, h, w);
		cout << res.gr << ' ' << res.mn - Min << '\n';
	}

	return 0;
}

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

int a, b;

int main(void){
  // Here your code !
  scanf("%d %d", &a, &b);
  if ((a * b * 1) % 2 == 1 || (a * b * 2) % 2 == 1 || (a * b * 3) % 2 == 1) {
    printf("Yes\n");
  }
  else {
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));



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



	int A,B;
	cin >> A>>B;

	if (!(A % 3) || !(B % 3) || !((A + B) % 3))
		cout << "Possible" << endl;
	else
		cout << "Impossible" << endl;
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int n;
    scanf("%d", &n);
    int h[n];
    for(int i=0; i<n; i++){
        scanf("%d", &h[i]);
    }
    int max = 0, buf = 0;
    for(int i=0; i<n-1; i++){
        if(h[i] >= h[i+1]){
            buf++;
        }else{
            buf = 0;
        }
        if(max < buf){
            max = buf;
        }
    }
    printf("%d", max);

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>


int n, q;
std::vector<int> A, ms;

bool solve(int m, int i) {
  if (m == 0)
    return true;
  if (i >= n)
    return false;
  return solve(m - A[i], i + 1) || solve(m, i + 1);
}

int main() {
  std::cin >> n;
  for (int i = 0; i < n; ++i) {
    int a;
    std::cin >> a;
    A.push_back(a);
  }
  std::cin >> q;
  for (int i = 0; i < q; ++i) {
    int m;
    std::cin >> m;
    ms.push_back(m);
  }
  for (int m : ms) {
    std::cout << (solve(m, 0) ? "yes" : "no") << std::endl;
  }
}

Measured memory_bytes: 3172
#include<stdio.h>

static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;
int m[100][100];

int prim(){ //最小全域木を求める
  int u,minv,v,i;
  int d[MAX],p[MAX],color[MAX];

  for(i=0;i<n;i++){
    d[i]=INFTY;
    p[i]=-1;
    color[i]=WHITE;
  }

  d[0]=0;

  while(1){
    minv=INFTY;
    u=-1;
    for(i=0;i<n;i++){
      if(minv>d[i] && color[i] != BLACK){
	u=i;
	minv=d[i];
      }
    }
    if(u==-1)break;
    color[u]=BLACK;
    for(v=0;v<n;v++){
      if(color[v]!=BLACK && m[u][v] != INFTY){
	if(d[v]>m[u][v]){
	  d[v]=m[u][v];
	  p[v]=u;
	  color[v]=GRAY;
	}
      }
    }
  }
  int sum = 0;
  for(i=0;i<n;i++){
    if(p[i]!=-1) sum+=m[i][p[i]];
  }
  return sum;
}

int main(){
  int i,j,e;
  
  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&e);
      m[i][j]=(e==-1)?INFTY:e;
    }
  }
  printf("%d\n",prim());
  return 0;
}



Measured memory_bytes: 2040
from operator import itemgetter

n = int(input())
dictionary = []

for i in range(1, n+1):
  s, p = input().split()
  p = int(p)
  dictionary.append([i, s, -p])

dictionary.sort(key=itemgetter(1, 2))

for i in range(n):
  print(dictionary[i][0])

Measured memory_bytes: 3060
import java.util.Scanner;
public class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        int total = a + b + c;
        
        if (total == 17) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 9808
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

const int64_t MOD = 1e9 + 7;

template <typename F>
void forComb(int n, int k, F f)
{
    int comb = (1 << k) - 1;
    while (comb < (1 << n)) {
        f(comb);

        int x = comb & -comb;
        int y = comb + x;
        comb = ((comb & ~y) / x >> 1) | y;
    }
}

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

    vector<vector<bool>> a(n, vector<bool>(n));
    rep(i, n) rep(j, n)
    {
        int b;
        cin >> b;
        a[i][j] = (b == 1);
    }

    vector<int64_t> dp(1 << n);
    irep(i, n)
    {
        if (i == 0) {
            dp[0] = 1;
        } else {
            forComb(n, i, [&](int comb) {
                dp[comb] = 0;
                rep(j, n)
                {
                    if ((comb & (1 << j)) != 0) {
                        int pcomb = comb ^ (1 << j);
                        if (a[n - i][j]) {
                            dp[comb] += dp[pcomb];
                            dp[comb] %= MOD;
                        }
                    }
                }
            });
        }
    }
    cout << dp[(1 << n) - 1] << endl;

    return 0;
}

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

#define PI 3.14159265358979323846264338327950288419

using namespace std;

int k;

int gcd(int a, int b){
	if(b == 0) return a;
	else return gcd(b, a % b);
}

int main(){
	int ans = 0;
	scanf("%d", &k);
	for(int i = 1; i <= k; i++){
		for(int j = 1; j <= k; j++){
			for(int l = 1; l <= k; l++){
				ans += gcd(gcd(i, j), l);
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3788
import java.io.PrintWriter;
        import java.util.ArrayList;
        import java.util.Collections;
        import java.util.List;
        import java.util.Scanner;

public class Main {
    static private Scanner scan = new Scanner(System.in);
    public static void main(String args[]) {
        int int1 = Integer.parseInt(scan.next());
        int int2 = Integer.parseInt(scan.next());
        String ans = null;
        if(int1 > int2){
            ans = String.valueOf(int1-1);
        }else{
            ans = String.valueOf(int1);
        }
        if(int1 == int2 && int2 == 1){
            ans = String.valueOf(1);
        }
        PrintWriter out = new PrintWriter(System.out);
        out.println(ans);
        out.flush();
        scan.close();
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(void){
	int a,b,q,i,ii,j,R1,R2=0;int len;
	string p,str,command,r,Reverse;
	while(cin>>str,cin>>q){
		for(i = 0;i < q;i++){
			cin>>command;
			if(command == "print"){
				cin>>a>>b;
				cout<<str.substr(a,b-a+1)<<endl;
			}
			if(command == "reverse"){
				cin>>a>>b;
				string A;
				A = str.substr(a,b-a+1);
				reverse(A.begin(),A.end());
				/*
				len = str.substr(a,b).length();
				for(R1 = len ; 0<R1;R1--){
					r[R2] += str.substr(a,b)[R1];
					R2++;
				}
				R2 = 0;
				str = str.substr(0,a) + r + str.substr(b,str.length());
				/*
				Reverse = str.substr(a,b);
				for(R1=0,R2=str.substr(a,b).size();R1<str.substr(a,b).size(),R2>0;R1++,R2--){
					r+= Reverse[R2] ;
				}*/
				//str = str.substr(0,a) + str.substr(a,b-a+1) + str.substr(b,str.substr(a,b).length());
				str.replace(a,b-a+1,A);

			}
			
			if(command == "replace"){
				cin>>a>>b>>p;		
				str.replace(a,b-a+1,p);
			
			}
		}
	}
	return 0;
}

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

int main()
{
    int x[3],k;
    for(int i = 0; i < 3; i++)
        cin >> x[i];
    cin >> k;

    for(int i = 0; i < k; i++) *max_element(x,x+3) *= 2;

    cout << x[0]+x[1]+x[2] << endl;

    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	var n int
	var s string
	fmt.Scanf("%d", &n)
	fmt.Scanf("%s", &s)

	fmt.Printf("%d", strings.Count(s, "ABC"))
}


Measured memory_bytes: 640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author niko
 */
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);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String c = in.readString();
            if (c.charAt(0) >= 'A' && c.charAt(0) <= 'Z') {
                out.println('A');
            } else
                out.println('a');
        }

    }

    static class InputReader {
        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar;
        private int snumChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (snumChars == -1)
                throw new InputMismatchException();
            if (curChar >= snumChars) {
                curChar = 0;
                try {
                    snumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (snumChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String readString() {
            int c = read();
            while (isSpaceChar(c)) c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



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

#define rep(i,l,r) for(int i=(l);i<(r);i++)
#define pb push_back
#define fi first
#define se second

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}

int main() {
	ll n, m; cin >> n >> m;
	ll t[200005];
	rep(i, 0, n) cin >> t[i];
	ll ans = 0;
	rep(i, 1, n){
		if((t[i]-t[i-1])>m) ans += m;
		else ans += t[i]-t[i-1];
	}
	ans += m;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5128
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl '\n'
int M = 1e9 + 7;
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  cin >> s;
  if (s[1] == 'R')
    s[1] = 'B';
  else
    s[1] = 'R';
  cout << s;
}

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

#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define eof !cin.eof()
#define pb push_back
#define pf push_front
#define pof pop_front
#define pob pop_back
#define ull unsigned long long
#define ll long long
#define ld long double
#define sz(a) a.size()
#define all(s) s.begin(), s.end()
#define rall(s, n) s, s + n
#define x first
#define y second
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define ii pair <int, int>
#define iii pair <int, ii>
#define vi vector <int>
#define vit vector <int> :: iterator
#define vlt vector <ll> :: iterator
#define vl vector <ll> 
#define vii vector <ii>
#define viii vector <iii>
#define vd vector <double>
#define vull vector <ull>
#define vc vector <char>
#define vs vector <string>
#define vvi vector <vector <int>>
#define vvl vector <vector <ll>>
#define EPS 1e-10
#define mod 1000000007
#define reset(a, nilai) memset(a, nilai, sizeof(a))
#define minof min_element
#define maxof max_element
using namespace std;

const ll INF = 1e18L + 5;
int n, W, w;
void min_self(ll &a, ll b) {
	a = min(a, b);
}
void max_self(ll &a, ll b) {
	a = max(a, b);
}
int main () {
	IOS;
	
	scanf("%d%d", &n, &W);
	vi w(n), v(n);
	int sum_value = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d%d", &w[i], &v[i]);
		sum_value += v[i];
	}
	vl dp(sum_value + 5, INF);
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = sum_value - v[i]; j >= 0; j--) {
			min_self(dp[j + v[i]], dp[j] + w[i]); // jika barang ke-i tidak diambil maka j + w
		}
	}
	ll answer = 0;
	for (int i = 0; i <= sum_value; i++) {
		if (dp[i] <= W) {
			max_self(answer, (ll) i);
		}
	}
	printf("%lld\n", answer);
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,k;
    cin >> n >> k;
    ll h[n];
    rep(i,n) cin >> h[i];
    ll dp[n+110];
    rep(i,n+110) dp[i] = inf;
    dp[0] = 0;
    rep(i,n)
    {
        REP(j,1,k+1)
        {
            dp[i+j] = min(dp[i+j], dp[i]+abs(h[i]-h[i+j]));
        }
    }
    cout << dp[n-1] << endl;
}


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

int main(void){
	int n;
	int a[200];
	int swap = 0;

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

	for(int i=0; i<n; i++){
		for(int j=n-1; j>i; j--){
			if(a[j] < a[j-1]){
				int temp = a[j];
				a[j] = a[j-1];
				a[j-1] = temp;
				swap++;
			}
		}
	}

	for(int i=0; i<n; i++){
		if(i!=n-1) printf("%d ", a[i]);
		else printf("%d\n", a[i]);
	}
	printf("%d\n", swap);

	return 0;
}

Measured memory_bytes: 1144
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A: Multiple of 2 and N
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  printf("%d\n", (n & 1) ? n * 2 : n);
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  long long int a;
  scanf("%lld",&a);
  int b=11;
  for(long long int i=1; i*i<=a; i++){
    if(a%i!=0){continue;}
    long long int c=a/i;
    int d=0;
    while(c>0){c=c/10;d++;}
    if(b>d){b=d;}
  }
  printf("%d",b);
  return 0;}


Measured memory_bytes: 128
#include <iostream>
#include <map>
#include <string>
using namespace std;
int main()
{
 int i,x,m,n,c,w;
 string s;
 c=w=0;
 map<int,int> wa;
 map<int,int> ac;
 cin >> n >> m;
 while(m--)
 {
  cin >> x >> s;
  if(s=="AC")
  {
   if(ac.find(x)==ac.end())
   {
    c++;
    if(wa.find(x)!=wa.end())
    w+=wa[x];
   }
   ac[x]=1;
  }
  else
  wa[x]++;
 }
 cout << c << " " << w;
 return 0;
}

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

int main(){
    string s;
    cin>>s;
    int ans=700;
    if(s[0]=='o')ans+=100;
    if(s[1]=='o')ans+=100;
    if(s[2]=='o')ans+=100;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

struct Node {
	int pos;
	std::vector<int> connects;
	int belongsTo;
};

Node nodes[100010];

int n, m;
int nextBelongs;

void doFill(int start, int nextBelongs) {
	std::queue<int> q;
	q.push(start);
	
	int curP, nextP;
	curP = start;
	nodes[curP].belongsTo = nextBelongs;	
	
	while (!q.empty()) {
		curP = q.front();
		q.pop();
		
		for (int i = 0 ; i < nodes[curP].connects.size() ; i++ ) {
			int newP = nodes[curP].connects[i];			
			if (nodes[newP].belongsTo == -1) {
				nodes[newP].belongsTo = nextBelongs;
				q.push(newP);
			}
		}
	}
}


int main()
{
	scanf("%d%d", &n, &m);
	
	for (int i = 1 ; i <= n ; i++) {
		nodes[i].pos = i;
		nodes[i].belongsTo = -1;
	}
	
	int u, v;
	for (int i = 0 ; i < m ; i++) {
		scanf("%d%d", &u, &v);
		nodes[u].connects.push_back(v);
		nodes[v].connects.push_back(u);
	}
	
	nextBelongs = 0;

	for (int i = 1 ; i <= n ; i++) {
		if (nodes[i].belongsTo != -1)
			continue;
			
		doFill(i, nextBelongs);
		nextBelongs++;
	}
	
	int ans = nextBelongs - 1;
	printf("%d\n", ans);
	

	return 0;
}


Measured memory_bytes: 9984
import java.util.Scanner;

public class Main {
	  
	public static void main(String args[]) {
		    Scanner scanner = new Scanner(System.in);
		    
			int N = scanner.nextInt();
			
			if( N % 4 == 0 ) 
			{ 
				System.out.println("Yes");
			}
			else 
			{
				if( N >= 7 ) 
				{
					N = N - 7;
					if( N % 4 == 0 ) 
					{
						System.out.println("Yes");
					}
					else 
					{
						if( N >=  7)
						{
							N = N - 7;
							if( N % 4 == 0) 
							{
								System.out.println("Yes");
							}
							else 
							{
								if( N >= 7 ) 
								{
									N = N - 7;
									if( N % 4 == 0 ) 
									{
										System.out.println("Yes");
									}
									else 
									{
										System.out.println("No");
									}
								}
								else 
								{
									System.out.println("No");
								}
							}
						}
						else 
						{
							System.out.println("No");
						}
					}
				}
				else 
				{
					System.out.println("No");
				}
			}
		    scanner.close(); }
		  }

Measured memory_bytes: 23764
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        final int A = sc.nextInt();
        final int B = sc.nextInt();
        final int C = sc.nextInt();
        final int X = sc.nextInt();
        final int Y = sc.nextInt();

        if (A + B < C * 2) {
            System.out.println(A*X + B*Y);
        } else {
            final int MAX = Math.max(X, Y);
            final int MIN = Math.min(X, Y);
            final int DIF = MAX - MIN;
            int ans = C * 2 * MIN;

            final int Z = C * 2 * DIF;
            if (X > Y && A * DIF < Z) ans += A * DIF;
            if (X > Y && A * DIF > Z) ans += Z;
            if (X < Y && B * DIF < Z) ans += B * DIF;
            if (X < Y && B * DIF > Z) ans += Z;
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 21972
import java.util.Scanner;

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

		// 入力値の取得
		int N = sc.nextInt();
		
		// 結果の出力
		int tmp = 1;
		int count = 0;
		for (int i = 1; i <= N; i++) {
			if (sc.nextInt() == tmp) {
				tmp++;
			}
			else {
				count++;
			}
		}
		System.out.println(tmp == 1? -1 : count);
		
		sc.close();
	}
}


Measured memory_bytes: 58752
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())



int n;
int x[100];
int y[100];
bool used[100];


long long calc(int dim, int sign) {
	long long X = 0, Y = 0;
	memset(used, false, sizeof(used));
	rep(i, n) {
		if (dim == 0) {
			if (x[i] * sign > 0) {
				X += x[i];
				Y += y[i];
				used[i] = true;
			}
		}
		else {
			if (y[i] * sign > 0) {
				X += x[i];
				Y += y[i];
				used[i] = true;
			}
		}
	}

	while (1) {
		bool update = false;
		rep(i,n) {
			long long NX = X, NY = Y;
			if (used[i]) {
				NX -= x[i];
				NY -= y[i];
			}
			else {
				NX += x[i];
				NY += y[i];
			}

			if (X * X + Y * Y < NX * NX + NY * NY) {
				X = NX;
				Y = NY;
				used[i] = !used[i];
				update = true;
			}
		}
		if (!update) {
			rep(j, n) {
				rep(i, j) {
					long long NX = X, NY = Y;
					if (used[i]) {
						NX -= x[i];
						NY -= y[i];
					}
					else {
						NX += x[i];
						NY += y[i];
					}
					if (used[j]) {
						NX -= x[j];
						NY -= y[j];
					}
					else {
						NX += x[j];
						NY += y[j];
					}


					if (X * X + Y * Y < NX * NX + NY * NY) {
						X = NX;
						Y = NY;
						used[i] = !used[i];
						used[j] = !used[j];
						update = true;
					}
				}
			}
		}

		if (!update)break;
	}


	return X * X + Y * Y;
}




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

	cin >> n;
	rep(i, n)cin >> x[i] >> y[i];


	double ans = sqrt(max({ calc(0,1), calc(0,-1), calc(1,1), calc(1,-1) }));

	printf("%.12f\n", ans);

	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)

coordinate_number,distance = map(int, input().split())

within_distance = 0
square_distance = distance*distance
for i in range(coordinate_number):
  x,y = map(int, input().split())
  if square_distance >= x*x + y*y:
    within_distance += 1

print(within_distance)


Measured memory_bytes: 9136
#include <stdio.h>
#include <stdlib.h>

int main(void){
        int n;
        int i=scanf("%d",&n);
        if(i<1){
                printf("error");
                exit(1);
        }
        int l[n];
        long snuke[n];
        int e=0;
        for(int i=0;i<n;i++){
                e=scanf("%d",&l[i]);
                if(e<1){
                        printf("error");
                        exit(1);
                }
        }

        long sum=0;
        for(int i=0;i<n;i++){
                sum+=l[i];
                snuke[i]=sum;
        }

        long sub=0;
        long min=0;
        sub=2*snuke[0]-sum;
        if(sub<0){
                sub=-sub;
        }
        min=sub;
        for(int i=0;i<n-1;i++){
                sub=2*snuke[i]-sum;
                if(sub<0){
                        sub=-sub;
                }
                if(sub<min){
                        min=sub;
                }
        }
        printf("%ld",min);
        return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define lg length()
#define sz size()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005
#define x1 nibab
#define y1 kebab

string a,b;

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> a >> b;
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    reverse(b.begin(),b.end());
    if(a<b) cout << "Yes";
    else cout << "No";
}


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

using ll = long long;
ll dp[100001][3];
int arr[100001][3];
int n;

int main(){
    ios::sync_with_stdio(false);
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
    }
    for(int i = 1; i <= n; i++){
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + arr[i][0];
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + arr[i][1];
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + arr[i][2];
    }
    cout << *max_element(dp[n], dp[n] + 3) << endl;
}


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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int,int> p;

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

#define MAX_N 100100
int N,K;
vector<int> edge[MAX_N];
vector<int> tree_edge[MAX_N];
vector<int> lift_edge[MAX_N];
unordered_map<int ,unordered_map<int, unordered_map<int, int> > > dp;
int level[MAX_N];
vector< p > sec;
vector<int> num;

p overlap(p &a, p &b) {
    int l = max(a.first,b.first);
    int r = min(a.second,b.second);
    p ret = p(l,r);
    if (r<l) {
        cout << "No" << endl;
        exit(0);
    }
    return ret;
}

void makeTree(int node, int pre) {
    level[node] = level[pre]+1;
    for(auto x:edge[node]) {
        if(level[x]==-1) {
            tree_edge[node].pb(x);
            lift_edge[x].pb(node);
            makeTree(x,node);
        }
    }
}

void lift(int node,p &pre){
    if (level[node]) return;
    if (dp[node][pre.first][pre.second]) return;
    dp[node][pre.first][pre.second]=1;
    p ret = p(pre.first-1,pre.second+1);
    sec[node] = overlap(sec[node], ret);
    if (ret.first==ret.second) level[node]=1;
    if (lift_edge[node].size()==0) return;
    // 同じ処理を省く
    lift(lift_edge[node][0],sec[node]);
}

void decend(int node, p &pre) {
    p ret = p(pre.first-1,pre.second+1);
    ret = overlap(ret, sec[node]);
    num[node] = ret.first;
    ret = p(num[node],num[node]);
    for (auto x: tree_edge[node]) {
        decend(x, ret);
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin >> N;
    num.resize(N,INF);
    REP(i,N-1) {
        int a,b;
        cin >> a >> b;
        a--;b--;
        edge[a].pb(b);
        edge[b].pb(a);
    }
    cin >> K;
    int st = 0;
    REP(i,K) {
        int v, p;
        cin >> v >> p;
        v--;
        num[v]=p;
        if (i==0) {
            st = v;
        }
    }
    
    fill(level,level+N+1,-1);
    makeTree(st,N);
    REP(i,N) edge[i].resize(0);

    
    //　偶奇のチェック
    REP(i,N) {
        if(num[i]!=INF) {
            if(level[i]%2) {
                if(num[i]%2==num[st]%2) {
                    cout << "No" << endl;
                    return 0;
                }
            }
            else {
                if(num[i]%2!=num[st]%2) {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    
    // 区間を決める
    fill(level,level+N+1,0);
    sec.resize(N);
    REP(i,N) {
        if(num[i]!=INF) sec[i]=p(num[i],num[i]);
        else sec[i]=p(-INF,INF);
    }
    
    REP(i,N) {
        if(tree_edge[i].size()==0) {
            p tmp = p(-INF,INF);
            lift(i,tmp);
        }
    }
    
    p tmp = p(-INF,INF);
    decend(st,tmp);
    
    cout << "Yes" << endl;
    REP(i,N) {
        cout << num[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 54180