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

object Main extends App {
  val sc = new Scanner(System.in)
  val ans = (sc.nextInt, sc.nextInt) match {
    case (w, h) if w % 3 == 0 || h % 3 == 0 => 0
    case (w, h) =>
      val init = w min h
      val a = aaa(w, h)
      val b = aaa(h, w)
      init min a min b
  }
  println(ans)

  def aaa(a: Int, b: Int): Int = {
    val xxx = for {
      aa <- List(a / 3, a / 3 + 1)
    } yield {
      val b1 = b / 2
      val b2 = b - b1
      val x1 = aa * b
      val x2 = (a - aa) * b1
      val x3 = (a - aa) * b2
      (x1 max x2 max x3) - (x1 min x2 min x3)
    }
    xxx(0) min xxx(1)
  }
}


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

class Node {
	public:
	int value;
	set<int> neighborIndex;
	bool isVisited = false;
};

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

	vector<Node> nodes(N);
	vector<int> c(N);
	for (int i = 0; i < N-1; i++)
	{
		int a , b;
		cin >> a >> b;
		a--;
		b--;
		nodes[a].neighborIndex.insert(b);
		nodes[b].neighborIndex.insert(a);
	}
	for (int i = 0; i < N; i++)
	{
		cin >> c[i];
	}
	
	sort(c.rbegin(), c.rend());
	

	queue<int> q;
	q.push(0);
	nodes[0].isVisited = true;

	int sum = -c[0];
	int i = 0;

	while(!q.empty())
	{
		int nodeindex = q.front();
		q.pop();
		for(int nei: nodes[nodeindex].neighborIndex)
		{
			if(nodes[nei].isVisited == false)
			{
				q.push(nei);
				nodes[nei].isVisited = true;
			}
		}
		nodes[nodeindex].value = c[i];
		sum += c[i];
		i++;
	}
	cout << endl;
	
	cout << sum << endl;
	for (int i = 0; i < N; i++)
	{
		cout << nodes[i].value << " ";
	}
	cout << flush;
	
	
	return 0;
}

Measured memory_bytes: 1920
import math

a,b,cc=map(float,input().split())
sinc=math.sin(math.radians(cc))
cosc=math.cos(math.radians(cc))
c2=a*a+b*b-2*a*b*cosc

c=math.sqrt(c2)


S=(a*b*sinc)/2
L=a+b+c
H=b*sinc


print('{:.8f}'.format(S))
print('{:.8f}'.format(L))
print('{:.8f}'.format(H))


Measured memory_bytes: 5696
mod = 10**9+7
from collections import defaultdict
N = int(input())
A = list(map(int,input().split()))

def prime_decomposition(n):
  i = 2
  d = {}
  while i * i <= n:
    while n % i == 0:
      n //= i
      if i not in d:
          d[i] = 0
      d[i] += 1
    i += 1
  if n > 1:
    if n not in d:
        d[n] = 1
  return d

da = defaultdict(lambda:0)
for i in range(N):
    d = prime_decomposition(A[i])
    for k in d:
        da[k] = max(da[k],d[k])
m = 1
for k in da:
    m *= pow(k,da[k],mod)
    m %= mod
ans = 0
for i in range(N):
    ans += m*pow(A[i],mod-2,mod)
    ans %= mod
print(ans)

Measured memory_bytes: 46172
def main():
    n = int(input())
    a = list(map(int, input().split()))
    lim = [None]*(n+1)
    f = True
    lim[0] = 1 - a[0]
    for i in range(1, n+1):
        lim[i] = lim[i-1]*2
        lim[i] -= a[i]
    ans = 0
    pre = 0
    for i in reversed(range(n+1)):
        if (pre+1)//2 > lim[i]:
            f = False
            break
        x = a[i] + min(lim[i], pre)
        ans += x
        pre = x
    if f:
        print(ans)
    else:
        print(-1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 668508
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ;; $n:expr) => {
        (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
    };
}

fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn main() {
    let (a, b) = get!(u64, u64);

    let mut r = 0;
    let mut i: u64 = 1;
    let mut ps: Vec<u64> = Vec::new();
    while i.pow(2) <= a {
        if a % i == 0 {
            ps.push(i);
            if i != a/i {
                ps.push(a/i);
            }
        }
        i += 1;
    }
    ps.sort();
    let mut x = 1;
    for p in ps.into_iter() {
        if b % p == 0 && gcd(x, p) == 1 {
            x *= p;
            r += 1;
        }
    }
    println!("{}", r);
}

Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
using namespace std;
int main() {
	int n;
	cin >> n;
	string s = to_string(n);
	int wa = 0;
	for (int i = 0; i < s.size(); i++) {
		wa += s[i] - '0';
	}
	if (n%wa == 0)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        if( s.contains("a") && s.contains("b") && s.contains("c")) {
            System.out.println("Yes");
        }
        else {
            System.out.print("No");
        }
    }
}


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

int main(){
  int N,*A,i,flag,a,count=0;

  scanf("%d",&N);
  A=(int*)malloc(N*sizeof(int));
  for(i=0;i<N;i++)  scanf("%d",&A[i]);
  flag=1;
  while(flag){
    flag=0;
    for(i=N-1;i>0;i--){
      if(A[i]<A[i-1]){
	a=A[i];
	A[i]=A[i-1];
	A[i-1]=a;
	count++;
	flag=1;
      }
    }
  }
  printf("%d",A[0]);
  for(i=1;i<N;i++)printf(" %d",A[i]);
  printf("\n%d\n",count);
  close(A);
  return 0;
}

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

using namespace std;

int main(){
	//freopen("i.txt","r",stdin);
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	
	int a[n];
	int b[n];
	
	int x[n];
	int y[n];
	
	map<int,int> fw;
	for(int i = 0;i < n;i++){
		cin >> a[i];
		x[i] = a[i];
	}
	
	for(int i = 0;i < n;i++){
		cin >> b[i];
		y[i] = b[i];
		fw[a[i]] = b[i];
	}
	
	sort(x,x+n);
	sort(y,y+n);

	
	map<int,int> nxt;
	for(int i = 0;i < n;i++){
		if(x[i] > y[i]){
			cout << "No";
			return 0;
		}
		nxt[y[i]] = x[i];
	}
	
	for(int i = 0;i < n;i++){
		if(i != 0 && x[i] <= y[i-1]){
			cout << "Yes";
			return 0;
		}
	}
	

	
	int u = a[0];
	set<int> vis;
	while(true){
		//cout << u << "\n";
		if(vis.find(u) != vis.end()) break;
		vis.insert(u);
		u = nxt[fw[u]];
	}
	
	if(vis.size() != n){
		cout << "Yes";
		return 0;
	}
	cout << "No";
	return 0;
}


Measured memory_bytes: 15872
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx") 
#include <bits/stdc++.h>
#include <ext/pb_ds/priority_queue.hpp>
using namespace std;
using namespace __gnu_pbds;
#define F(i,a,b) for(int i=(a);i<=(b);++i)
#define F2(i,a,b) for(int i=(a);i<(b);++i)
#define dF(i,a,b) for(int i=(a);i>=(b);--i)
#define dF2(i,a,b) for(int i=(a);i>(b);--i)
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define Debug debug("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define INF 0x3f3f3f3f
#define INFll 0x3f3f3f3f3f3f3f3f
#define y0 _lxybz_
#define y1 _ljmnzyzhhhoscartxdy_
typedef long double ld;
typedef long long ll;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize
#define lo(x) ((x)&(-(x)))
#define trav(a, x) for (auto &a : x)
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
const ld Pi = 4*atan((ld)1);
template<class T> void chmin(T &a,const T&b) { a = min(a, b); }
template<class T> void chmax(T &a,const T&b) { a = max(a, b); }
namespace IO{
template<class T> inline void read(T&ret)
{
	ret=0; int f=1; char c=getchar();
	while(c<48||c>57){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>=48 && c<=57)ret=ret*10+c-48,c=getchar();
	ret*=f;
}
template<class T> inline void prin(const T&ret)
{
	if(!ret){putchar(48);return;} static T o; o=ret;
	if(o<0){putchar('-');o=-o;}
	static int op[25],tt; tt=0;
	while(o){
		op[++tt]=o%10;
		o/=10;
	}
	for(int i=tt;i;--i)putchar(op[i]+48);
}
template<class T> inline void pri_(const T&ret)
{
	prin(ret);putchar(' ');
}
template<class T> inline void priE(const T&ret)
{
	prin(ret);putchar('\n');
}
}
using namespace IO;

#define N 300005
#define MO 

struct node {
	int l, r;
	bool operator < (const node & a)const {
		return l<a.l;
	}
}A[N];
int H[N],h[N],t,n,l,x;
inline void add(int p,int x)
{
	for(;p<=t;p+=lo(p))chmax(h[p],x);
}
inline int que(int p)
{
	int s=0;
	for(;p;p-=lo(p))chmax(s,h[p]);
	return s;
}

inline void _Sol_()
{
	read(n);
	F(i,1,n){
		read(x); read(l);
		A[i].l=x-l;A[i].r=x+l;
		H[++t]=A[i].l;H[++t]=A[i].r;
	}
	sort(H+1,H+t+1);
	t=unique(H+1,H+t+1)-H-1;
	F(i,1,n){
		A[i].l=lower_bound(H+1,H+t+1,A[i].l)-H;
		A[i].r=lower_bound(H+1,H+t+1,A[i].r)-H;
	}
	sort(A+1,A+n+1); //l
	F(i,1,n){
		x=que(A[i].l);
		add(A[i].r,x+1);
	}
	cout<<que(t);
}

int main()
{
	int T=1; //read(T);
	while(T--)_Sol_();
}

Measured memory_bytes: 3840
use std::io::*;
use std::str::FromStr;

fn main() {
	let n: usize = read();
	let m: usize = read();
	let mut v = vec![0; n];
	let (mut s, mut c): (usize, i8);
	for _ in 0..m {
		s = read();
		c = read();
		if n == 1 && (s, c) == (1, 0) {
			v[0] = 0;
		} else if (s, c) == (1, 0) {
			v[0] = -1;
		} else if v[s-1] == 0 {
			v[s-1] = c;
		} else if v[s-1] != c {
			v[0] = -1;
		}
	}
	if v[0] == 0 && n != 1 {
		v[0] = 1;
	}
	if v[0] == -1 {
		print!("-1");
	} else {
		for i in &v {
			print!("{}", i);
		}
	}
			println!("");
}



fn read<T: FromStr>() -> T {
	let stdin = stdin();
	let stdin = stdin.lock();
	let token: String = stdin
		.bytes()
		.map(|c| c.expect("failed to read char") as char)
		.skip_while(|c| c.is_whitespace())
		.take_while(|c| !c.is_whitespace())
		.collect();
	token.parse().ok().expect("failed to parse token")
}



Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
using namespace std;
int a[2010][2010];char s[2010];
int h[2010][2010],r[2010][2010],l[2010][2010];
int top=0,ans=0,st[2010];
int main()
{
	int n,m;scanf("%d%d",&n,&m);ans=n;
	for(int i=1;i<=n;i++)
	{
		scanf("%s",s);
		for(int j=1;j<=m;j++)a[i][j]=(s[j-1]=='#');
	}
	for(int i=n;i>=1;i--)
	for(int j=m;j>=2;j--)a[i][j]^=a[i][j-1];
	for(int j=2;j<=m;j++)h[1][j]=1;
	for(int i=2;i<=n;i++)
	for(int j=2;j<=m;j++)if(a[i][j]==a[i-1][j])h[i][j]=h[i-1][j]+1;else h[i][j]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=2;j<=m;j++)
		{
			while(top&&h[i][st[top]]>h[i][j]){r[i][st[top]]=j-1;top--;}
			st[++top]=j;
		}
		while(top)r[i][st[top--]]=m;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=2;j<=m;j++)
		{
			while(top&&h[i][st[top]]>=h[i][j]){top--;}
			if(top==0)l[i][j]=2;else l[i][j]=st[top]+1;st[++top]=j;
		}
		top=0;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=2;j<=m;j++)ans=max(ans,(r[i][j]-l[i][j]+2)*h[i][j]);
	}
	printf("%d",ans);return 0;
}

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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if(a + b <= a + c) {
        if(a + b <= b + c) cout << a + b;
        else cout << b + c;
    }else{
        if(a + c <= b + c) cout << a + c;
        else cout << b + c;
    }
}


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

public class Main
{
  static long t[];
  static long l[];
  static long h[];

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);

    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");
    int n = Integer.parseInt(sl[0]);
    int m = Integer.parseInt(sl[1]);

    int a[] = new int[m];
    for(int i = 0; i < n; i++)
    {
      s = r.readLine();
      sl = s.split(" ");
      int v = Integer.parseInt(sl[0]);
      for(int j = 1; j <= v; j++)
      {
        int t = Integer.parseInt(sl[j]) - 1;
        a[t]++;
      }
    }

    int sum = 0;
    for(int i = 0; i < m; i++)
    {
      //System.out.println(a[i]);
      if(a[i] == n)
      {
        sum++;
      }
    }
    System.out.println(sum);
  }

}

Measured memory_bytes: 22996
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
#include <numeric>
#include <sstream>
#include <queue>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()
#define print(s) cout << (s) << endl

typedef pair<int,long> P;

void solve100(int n) {
    
    vector<P> v(4001, make_pair(0,0));
    long o, p, q;
    int cnt = 1;
    REP(i,n) {
        cin >> o >> p >> q;
        if (v[o].first != 0) {
            v[o].second += p * q;
        }else {
            v[o].first = cnt;
            cnt++;
            v[o].second += p * q;
        }
    }
    vector<P> w;
    REP(i,4001) {
        if (v[i].second >= 1000000) w.push_back(make_pair(v[i].first, i));
    }
    sort(ALL(w));
    if (w.size()) {
        REP(i,w.size()) cout << w[i].second << endl;
    }else {
        cout << "NA" << endl;
    }
}

int main() {
    int n;
    while(cin >> n, n) {
        solve100(n);
    }
    return 0;
}

Measured memory_bytes: 1292
input_number = int(input())
 
a = input_number//1000
b = (input_number-1000*a)//100
c = (input_number-1000*a-100*b)//10
d = input_number-1000*a-100*b-c*10
if a==b:
	print('Bad')
elif b==c:
	print('Bad')
elif c==d:
	print('Bad')
else:
    print('Good')

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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int>v;
    for(int i = 0; i < n; ++i){
        int tmp; cin >> tmp;
        v.push_back(tmp);
    }
    sort(v.begin(), v.end());
    for(int i = 0; i < n - 1; ++i){
        if(v[i] == v[i + 1]){
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";
    return 0;

}


Measured memory_bytes: 1528
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>

using namespace std;
typedef long long ll;
typedef pair<int, int> p_ii;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

bool cmp(p_ii a, p_ii b){return a.second<b.second;}

int main() {
    int N,M;
    cin>>N>>M;
    vector<p_ii> ab(M);

    for (int i = 0; i < M; i++) {
        cin>>ab[i].first>>ab[i].second;
    }

    sort(ab.begin(),ab.end(),cmp);

    int res=0;
    int right=0;
    for (int i = 0; i < M; i++) {
        if(ab[i].first>=right){
            right=ab[i].second;
            res++;
        }
    }

    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		// スペース区切りの整数の入力
        int[] p = new int[n];
        for(int i=0;i<n;i++){
          p[i]=sc.nextInt();
        }
        
        int count=0;
        for(int i=1;i<n-1;i++){
         if(p[i]==mid(p[i-1],p[i],p[i+1]))
             count++;
        }
		// 出力
		System.out.println(count);
	}
  public static int mid(int a,int b ,int c){
    if(a >= b) {
    		if(b >= c) {
    			return b;
    		}
    		else if(a <= c) {
    			return a;
    		}
    		else {
    			return c;
    		}
    	}
    	else if(a > c) {
    		return a;
    	}
    	else if(b > c) {
    		return c;
    	}
    	else {
    		return b;
    	}
  }
    
}

Measured memory_bytes: 22100
#pragma comment(linker, "/stack:200000000")
 #pragma GCC optimize("Ofast")
 #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 #include<bits/stdc++.h>
 #define int long long
 using namespace std;


signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
//  #ifndef ONLINE_JUDGE
//     freopen ("INPUT.txt" , "r" , stdin);
//     freopen ("OUTPUT.txt" , "w" , stdout);
//  #endif
 
     clock_t clk;
 	clk = clock();
 
// -------------------------------------Code starts here--------------------------------------------------------------------- 

    int n;
    cin>>n;
    cout<<(n-1)/2;
// -------------------------------------Code ends here------------------------------------------------------
 
     clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }

Measured memory_bytes: 256
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws FileNotFoundException {

//    	File file = new File("src/in.txt");

        //コード
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);

    	int K = sc.nextInt();

    	int sum = 0;

    	for(int i=1;i<=K;i++) {
    		for(int j=1;j<=K;j++) {
    			for(int k=1;k<=K;k++) {
    				sum += gcd(i,gcd(j,k));
    			}
    		}
    	}
    	System.out.println(sum);

    }

    public static int gcd(int num1,int num2) {
        if(num2==0) return num1;
        else return gcd(num2,num1%num2);
    }

}


Measured memory_bytes: 27264
#include<stdio.h>

int main(void)
{
	int f1, t1, sum = 0;
	for(f1 = 1; f1 <= 4; f1++)
	{
		scanf("%d",&t1);
		sum += t1;
	}
	printf("%d\n%d\n",sum/60,sum%60);
	return 0;
}

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

int main() {
  ll n;
  cin >> n;
  map<string,ll> count;
  for(ll i=0;i<n;i++) {
    string s;
    cin >> s;
    count[s]++;
  }
  ll ma=0;
  for(auto p:count) {
    ma=max(ma,p.second);
  }
  for(auto p:count) {
    if(ma==p.second) {
      cout << p.first << endl;
    }
  }
}

Measured memory_bytes: 25216
import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    if (args.length > 0 && args(0) == "TEST") {
      println(test())
    } else {
      val input = io.Source.stdin.getLines().mkString("\n")
      println(solve(input).trim())
    }
  }

  def solve(input: String): String = {
    val s: Scanner = new Scanner(input)
    val n = s.nextInt
    var r: List[(String, Int, Int)] = Nil
    for (i <- 1 to n) {
      r = (s.next, s.nextInt, i) :: r
    }
    r.sortBy(elm => (elm._1, -elm._2)).map(elm => elm._3).mkString("\n")
  }

  val tests = List(
    """6
      |khabarovsk 20
      |moscow 10
      |kazan 50
      |kazan 35
      |moscow 60
      |khabarovsk 40
      |""".stripMargin ->
      """3
        |4
        |6
        |1
        |5
        |2
        |""".stripMargin,
    """10
      |yakutsk 10
      |yakutsk 20
      |yakutsk 30
      |yakutsk 40
      |yakutsk 50
      |yakutsk 60
      |yakutsk 70
      |yakutsk 80
      |yakutsk 90
      |yakutsk 100""".stripMargin ->
    """10
      |9
      |8
      |7
      |6
      |5
      |4
      |3
      |2
      |1
    """.stripMargin
  )

  def test(): String = tests.map { case (i, o) => (i.trim(), o.trim()) }
    .zipWithIndex.map {
    case ((input, outputExpect), i) =>
      val output = solve(input).trim()
      val tnum = i + 1
      s"test$tnum:" + (
        if (output == outputExpect) "Passed"
        else s"Failed\nexpect:\n$outputExpect\noutput:\n$output")
  }
    .mkString("\n")
}

Measured memory_bytes: 25764
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <fstream>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LL long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
int main(){
    int h,w; cin>>h>>w;
    int c[10][10];
    FOR(i,0,10){
        FOR(j,0,10){
            cin>>c[i][j];
        }
    }
    FOR(k,0,10){
        FOR(i,0,10){
            FOR(j,0,10){
                if(c[i][k]+c[k][j]<c[i][j]){
                    c[i][j]=c[i][k]+c[k][j];
                }
            }
        }
    }
    int sum=0;
    FOR(i,0,h){
        FOR(j,0,w){
            int a; cin>>a;
            if(a>=0){
                sum+=c[a][1];
            }
        }
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

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

    sort(l.begin(), l.end());

    int l_sum = 0;
    for (int i = 0; i < n - 1; i++) {
        l_sum += l[i];
    }

    cout << (l_sum > l[n - 1] ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let s: String = sc.cin();
    let c: Vec<char> = s.chars().collect();
    let mut ok = true;
    for i in 0..s.len() {
        if i % 2 == 1 && c[i] == 'R' {
            ok = false;
        } else if i % 2 == 0 && c[i] == 'L' {
            ok = false;
        }
    }
    if ok {
        put!("Yes");
    } else {
        put!("No");
    }
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}

main(){

  ll n;
  cin>>n;
  pair<ll,ll> res(0,0);
  rep(i,n){
    pair<ll,ll> a;
    cin>>a.first>>a.second;
    chmax(res,a);
  }
  cout<<(res.first+res.second)<<endl;

}

Measured memory_bytes: 256
import numpy as np

N=input()
nums=map(int,raw_input().split(' '))
num = np.zeros(100000,dtype='int')
for i in nums:
    num[i] = num[i] + 1
max=0
for i in range(100000-2):
    if max < num[i] + num[i+1] + num[i+2]:
        max = num[i] + num[i+1] + num[i+2]
print max

Measured memory_bytes: 19324
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = int_fast64_t;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;

template<class T> inline T sqr(T x) {return x*x;}

long long power(long long x, long long n, long long mod = 1000000007) {
    if (n == 0) return 1;
    if (n % 2 == 0) return power(x * x % mod, n/2, mod);
    else return x * power(x, n-1, mod) % mod;
}

void solve() {
    int n;
    cin >> n;
    VLL a(n);
    REP(i,0,n) cin >> a[i];
    VLL ru(n+1);
    LL k = 1;
    REP(i,1,n+1) k = (k * i) % MOD;
    REP(i,1,n+1) ru[i] = (ru[i-1] + power(i, MOD - 2)) % MOD;
    LL ans = 0;
    REP(i,0,n) {
        ans = (ans + (ru[i+1] + ru[n-i] - 1) * a[i]) % MOD;
    }
    cout << (ans * k) % MOD << endl;
}

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

Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define pye cout << "Yes" << endl;
#define pno cout << "No" << endl;
#define pYE cout << "YES" << endl;
#define pNO cout << "NO" << endl;
#define prin(num) cout << num << endl;
#define INF 1000000000
#define MOD 1000000007
#define MAX 100001
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PA;
typedef priority_queue<ll> PQ;
typedef pair<double, double> doup;
//typedef vector<ll> vec;
//typedef vector<vec> mat;

ll modpow(ll x, ll n) {
    ll res=1;
    
    while(n>0) {
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}


int main() {
    string s;
    cin >> s;
    for(ll i=0; i<s.size();) {
        if(s.substr(i, 13)=="dreamereraser") {
            i+=13;
        }else if(s.substr(i, 12)=="dreamererase") {
            i+=12;
        }else if(s.substr(i, 11)=="dreameraser") {
            i+=11;
        }else if(s.substr(i, 10)=="dreamerase") {
            i+=10;
        }else if(s.substr(i, 6)=="eraser") {
            i+=6;
        }else if(s.substr(i, 5)=="erase") {
            i+=5;
        }else if(s.substr(i, 7)=="dreamer") {
            i+=7;
        }else if(s.substr(i, 5)=="dream") {
            i+=5;
        }else {
            pNO;
            return 0;
        }
    }
    pYE;
    
}


Measured memory_bytes: 512
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;// ;//1000000000 + 7 998244353 924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max();
constexpr long long DINF = 1000000000000;
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<Edge>>g;
vector<edge>ed;
vector<Pll>pv;
map<LL, LL>ma;
set<LL>st;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
LL n, m, k, p, q, w, h, ans, cnt, sum[310000],a[310000], b[310000];
string str;
bool f;
char c[1100][1100];
int main() {
	cin >> n >> m;
	rep(i, m) {
		cin >> a[i] >> b[i];
		sum[a[i]]++;
		sum[b[i]+1]--;
	}
	rep(i, n) {
		sum[i + 1] += sum[i];
		if (sum[i] == m)ans++;
	}
	if (sum[n] == m)ans++;
	cout << ans << endl;
	return 0;
}


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

int main(){
  int k,a,b;
  cin >> k >> a >> b;
  string ans = "NG";
  
  for(int i = a; i<=b; i++) {
    if(i%k == 0) {ans = "OK";}
  }
  cout << ans << endl;
}

Measured memory_bytes: 3596
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main(){
  int x;
  cin>>x;
  
  if(x==3 || x==5 || x==7) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  
  return 0;
}

Measured memory_bytes: 3580
// In the name of God //
 
#include <bits/stdc++.h>
#define ll long long
#define all(x) (x).begin(), (x).end()
#define pii pair <int, int>
using namespace std;
const ll mod = 998244353;

void solve() {
    int n;
    cin >> n;
    vector<int> ans(n + 1);
    for (int x = 1; x <= 100; x++) {
        for (int y = 1; y <= 100; y++) {
            for (int z = 1; z <= 100; z++) {
                int res = x*x + y*y + z*z + x*y + y*z + x*z;
                if(res <= n)
                    ans[res]++;
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        cout << ans[i] << "\n";
    }
}

int main()  {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int tt = 1;
    // cin >> tt;
    for (int tc = 1; tc <= tt; ++tc) {
        solve();
    } 
    // cout << 15*modInverse(6, mod)%mod << " " << 39*modInverse(10, mod)%mod;
}                               

Measured memory_bytes: 3656
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

mod util {
    #[allow(dead_code)]
    pub fn chmin<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x > y && {
            *x = y;
            true
        }
    }

    #[allow(dead_code)]
    pub fn chmax<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x < y && {
            *x = y;
            true
        }
    }

    /// 整数除算切り上げ
    #[allow(dead_code)]
    pub fn roundup(a: i64, b: i64) -> i64 {
        (a + b - 1) / b
    }

    #[allow(dead_code)]
    pub fn ctoi(c: char) -> i64 {
        c as i64 - 48
    }
}

#[allow(unused_imports)]
use util::*;

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, VecDeque};

fn main() {
    input! {
        n:usize,
        ps:[usize;n]
    }

    let mut cnt = 0;
    for l in 0..n {
        if ps[l] != l + 1 {
            cnt += 1;
        }
    }
    if cnt <= 2 {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 4352
def enq(a,x)
  b = a[i=-1]
  until b.frozen?
    return a << x  if x >= (a=b)[-1]
    return a.unshift x  if x <= a[0]
    b = a[i = a.bsearch_index{|y| x < (y.frozen? ? y: y[0])}-1]
  end  if b && b=a
  return a.insert i+1, x  unless a[i+9]
  i>0 ? a[i]=[b,x] : enq(a[i+=1].to_a,x)  rescue a[i]=[x,a[i]]
end
def deq(a) r=a.pop; a.push *a.pop if !a[-1].frozen?; r end
NS = 6; NM = (1<<NS)-1
SS = 13;SM = (1<<SS)-1
F =-> {gets.split.map &:to_i}
N,M,S = F[]
E = Array.new(N) {|i| [i] }
M.times {
  u,v,a,b = F[]
  E[u-1] << [v-1,a,b]
  E[v-1] << [u-1,a,b]
}
E.each { |e| c,d = F[]; e[0] = [e[0], [-c,-2500].max, d] }
C,Q,V = [], [[S,2500].min], []
while C.size < N
  t = deq Q
  s = SM & t; t >>= SS
  n = NM & t; t >>= NS
  (v = V[n]) ? (next if v>=s || v>2500) : C << [n,t]
  V[n] = s
  E[n].each {|n,a,b| enq Q, (t-b<<NS+SS) + (n<<SS) + s-a  if s >= a }
end
puts C.sort[1,N].map{|i,t| -t}

Measured memory_bytes: 14396
#arc089c
import sys

def yn(s,x,y):
 r=abs(x)+abs(y)
 if s>=r and (s-r)%2==0:
  return True
 else:
  return False

n=int(raw_input())
s0,x0,y0=map(int,raw_input().split())
if yn(s0,x0,y0)==False:
 print 'No'
 sys.exit()
for i in xrange(n-1):
 s,x,y=map(int,raw_input().split())
 if yn(s-s0,x-x0,y-y0)==False:
  print 'No'
  sys.exit()
 s0,x0,y0=s,x,y
print 'Yes'


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

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

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

  char prev_digit;
  for (char digit : code) {
    if (prev_digit == digit) {
      cout << "Bad" << endl;
      return 0;
    }
    prev_digit = digit;
  }
  cout << "Good" << endl;
}


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

namespace _20170409_AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int t = 0;
            int h = 0;
            for (int i = 0; i < n; i++)
            {
                string[] sArr = Console.ReadLine().Split(' ');
                int cmp = sArr[0].CompareTo(sArr[1]);
                switch (cmp)
                {
                    case 1:
                        t += 3;
                        break;
                    case 0:
                        t += 1;
                        h += 1;
                        break;
                    case -1:
                        h += 3;
                        break;
                }
            }

            Console.WriteLine("{0} {1}", t, h);

            Console.ReadLine();
        }
    }
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
   
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    int l[n];
    for (int i=0;i<n;i++) cin>>l[i];
    sort(l,l+n);
    int cnt=0;
    for (int i=0;i<n;i++)
        for (int j=i+1;j<n;j++)
            for (int k=j+1;k<n;k++)
                if(l[i]+l[j]>l[k] and l[i]!=l[j] and l[j]!=l[k]) cnt++;
    cout<<cnt<<"\n";            
	return 0;
}

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

int main(){
  int h,w;
  cin >>h>>w;
  vector<vector<char>> img(h+1,vector<char>(w+1,'x'));
  for (int i=1;i<h+1;i++){
    for (int j=1;j<w+1;j++){
      cin>>img.at(i).at(j);
    }
  }
  vector<vector<char>> img2(2*h,vector<char>(w));
  for(int i=1;i<2*h+1;i++){
    for(int j=1;j<w+1;j++){
      img2.at(i-1).at(j-1) = img.at((i+1)/2).at(j);
      cout <<img2.at(i-1).at(j-1);
    }
    cout <<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 all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

vector<int> ans;
vector<vector<pair<int, ll>>> vec;
vector<int> visited;

void dfs(int node, ll dis){
  if(dis % 2 == 0) ans[node] = 0;
  else ans[node] = 1;
  visited[node] = 1;
  for(auto p : vec[node]){
    if(visited[p.first] == 0) dfs(p.first, dis+p.second);
  }
}

int main(){
  int n;
  cin >> n;
  rep(i, n) ans.push_back(0);
  rep(i, n) visited.push_back(0);
  rep(i, n) vec.push_back(vector<pair<int, ll>>());
  rep(i, n-1){
    int u, v;
    ll w;
    cin >> u >> v >> w;
    u--; v--;
    vec[u].push_back(make_pair(v, w));
    vec[v].push_back(make_pair(u, w));
  }
  dfs(0, 0);
  rep(i, n) cout << ans[i] << endl;
}
      
      

Measured memory_bytes: 11952
import bisect
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort()
B.sort()
C.sort()

BtoC = [0]*N
for i in range(N):
    BtoC[i] = N - bisect.bisect_right(C,B[i])
s = [0]*N
for i in range(N):
    i = N-1-i
    if i == N-1:
        s[i] = BtoC[i]
        continue
    s[i] = s[i+1]+BtoC[i]
res = 0
for a in A:
    ind = bisect.bisect_right(B,a)
    if ind >= N:
        break
    res += s[ind]
print(res)

Measured memory_bytes: 24540
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




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

  vector<pair<ll,ll>> r(n);
  rep(i,n){
    cin>>r[i].fi>>r[i].se;
  }

  ll ans=0;

  ll p,q;
  rep(i,n){
    rep(j,n){
      if(i==j) continue;
      p=r[i].fi-r[j].fi;
      q=r[i].se-r[j].se;
      if(p==0 && q==0) continue;
      ll cnt=0;

      vector<vector<bool>> ok(n,vector<bool>(n,true));

      rep(k,n){
        rep(l,n){
          if(ok[k][l]&&((p==r[k].fi-r[l].fi && q==r[k].se-r[l].se)
          ||(p==r[l].fi-r[k].fi && q==r[l].se-r[k].se))) {
            cnt++;
            ok[k][l]=false;
            ok[l][k]=false;
          }
        }
      }

      chmax(ans,cnt);
    }
  }


  cout << n-ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int pow_int(int a, int b){
    return (int)pow((double)a, (double)b);
}

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

    int x[n][d];
    for(int i=0; i<n; i++){
        for(int j=0; j<d; j++){
            scanf("%d", &x[i][j]);
        }
    }

    double sum;
    double tmp;
    int ans = 0;
    for(int i=0; i<n-1; i++){
        for(int j=i+1; j<n; j++){
            sum = 0.0;
            for(int k=0; k<d; k++){
                sum += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            }
            tmp = sqrt(sum);
            if(ceil(tmp) == floor(tmp)){
                ans += 1;
            }
        }
    }

    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
n = int(input())
A = list(map(int, input().split()))
A.insert(0,0)
A.append(0)
price = 0
for x in range(n+1):
    price += abs(A[x+1]-A[x])
for x in range(1, n+1):
    s = price
    s = s + abs(A[x-1]-A[x+1]) - (abs(A[x-1]-A[x])+abs(A[x]-A[x+1]))
    print(s)

Measured memory_bytes: 14044
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n, a, b; cin >> n >> a >> b;
	cout << (b - a & 1 ? "Borys" : "Alice") << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>

#define ll long long
#define vl vector<ll>
#define vvl vector< vector<ll> >
using namespace std;

int main(){
	string s; cin >> s;
	vl a(4);
	for (int i = 0; i < 4; ++i) a[i] = s[i] - '0';
	if (1 <= a[0] * 10 + a[1] && a[0] * 10 + a[1] <= 12){
		if (1 <= a[2] * 10 + a[3] && a[2] * 10 + a[3] <= 12) cout << "AMBIGUOUS" << endl;
		else cout << "MMYY" << endl;
	}
	else{
		if (1 <= a[2] * 10 + a[3] && a[2] * 10 + a[3] <= 12) cout << "YYMM" << endl;
		else cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	int n, w[100];
	cin >> n;
	int sum1=0, sum2=0;
	for(int i=0; i<n; i++){
		cin >> w[i];
		sum1+=w[i];
	}
	int ans=MOD;
	for(int i=0; i<n; i++){
		sum1-=w[i];
		sum2+=w[i];
		ans=min(ans, abs(sum1-sum2));
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
N, M, Q = map(int, input().split())
a = [0] * Q
b = [0] * Q
c = [0] * Q
d = [0] * Q
for i in range(Q):
    a[i], b[i], c[i], d[i] = map(int, input().split())
    a[i] -= 1
    b[i] -= 1

# スコア計算
def score(A):
    tmp = 0
    for ai, bi, ci, di in zip(a, b, c, d):
        if A[bi] - A[ai] == ci:
            tmp += di
    return tmp

# DFS
def dfs(A):
    if len(A) == N:
        return score(A) # 数列 A のスコアを返す
    res = 0
    prev_last = A[-1] if len(A) > 0 else 0
    for v in range(prev_last, M):
        A.append(v)
        res = max(res, dfs(A)) # 再帰呼出しながら、スコア最大値も更新
        A.pop()
    return res

print(dfs([]))

Measured memory_bytes: 9096
N = gets.to_i
As = gets.split.map(&:to_i)

even_sum = 0
As.each.with_index(1){ |v,i|
    even_sum += v if i % 2 == 0
}
x = As.inject(:+) - 2 * even_sum
ans = [x]
tmp = x

As.each{|a|
    next_x = 2 * a - tmp
    ans.push(next_x)
    tmp = next_x
}

ans.pop
puts ans.join(" ")

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

using namespace std;
using ll = long long;



int main()
{
    vector<ll> a(300);
    a[0] = 300000;
    a[1] = 200000;
    a[2] = 100000;
    int x, y;
    cin >> x >> y; x--; y--;
    ll ans = a[x] + a[y];
    if(x == y && x == 0)ans += 400000;
    cout << ans << endl;
}

Measured memory_bytes: 256
R=int(input())
s=input()
k=len(s)
n=R+k
MOD=10**9+7
factorials=[1]
current=1
for i in range(1,n+1):
  current=(current*i)%MOD
  factorials.append(current)
inverses=[]
for i in range(n+1):
  inverses.append(pow(factorials[i],MOD-2,MOD))
ans=0
for i in range(R+1):
  ans=(ans+factorials[n]*inverses[i+k]*inverses[n-i-k]*pow(25,n-k-i,MOD))%MOD
print(ans)

Measured memory_bytes: 173440
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
#define NUM 1000000000
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    long n,k,s;
    cin>>n>>k>>s;
    rep(i,k) cout<<s<<" ";
    repi(i,k,n){
        if(s<NUM) cout<<s+1<<" ";
        else cout<<1<<" ";
    }
}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <map>

using namespace std;

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


int main(){
  int x;
  cin >> x;
  int ans = 1;
  repd(i, 2, x){
    int tmp = i;
    while(tmp*i <= x){
      tmp = tmp*i;
      ans = max(ans, tmp);
    }
    // cout << i << endl;
    // cout << ans << endl;
    // ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}




Measured memory_bytes: 888