akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

struct Vertex
{
    vector<int> next;
    int p = 0;
};

Vertex V[100005];
bool isC[100005];
int Ans[100005];

int main()
{
    ll N, M;
    cin >> N >> M;
    REP(i, N - 1 + M)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        isC[b] = true;
        V[a].next.push_back(b);
        V[b].p++;
    }

    int root = -1;
    REP(i, N)
    {
        if (!isC[i])
        {
            root = i;
            break;
        }
    }

    Ans[root] = -1;
    queue<int> q;
    q.push(root);
    while (!q.empty())
    {
        int t = q.front();
        q.pop();
        REP(i, V[t].next.size())
        {
            int n = V[t].next[i];
            V[n].p--;
            if (V[n].p > 0)
                continue;
            Ans[n] = t;
            q.push(n);
        }
    }

    REP(i, N)
    {
        cout << Ans[i] + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 7552
import java.lang.*;
import java.io.*;
import java.util.*;


public class Main {
	
	public static void main(String[] args) throws java.lang.Exception {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(in, out);
		out.close();
	}
}

class TaskA {
	
	public void solve(InputReader in, PrintWriter out) {
		String s;
		StringBuilder sb = new StringBuilder();
		
		for (int i=0; i<3; ++i) {
			s = in.next();
			sb.append(s.charAt(0));
		}
		
		out.println(sb.toString());
	}
}

class InputReader {
	public BufferedReader reader;
	public StringTokenizer tokenizer;
	
	
	public InputReader(InputStream stream) {
		reader = new BufferedReader(new InputStreamReader(stream), 32768);
		tokenizer = null;
	}
	
	public String next() {
		while (tokenizer==null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	
	public int nextInt() {
		return Integer.parseInt(next());
	}
	
	public double nextDouble() {
		return Double.parseDouble(next());
	}
	
	public long nextLong() {
		return Long.parseLong(next());
	}
}


Measured memory_bytes: 23508
N = int(input())
A = list(map(int, input().split()))

ans = 0
n = [0] * 100005
for i in range(N):
    n[A[i]] += 1
    ans += A[i]
Q = int(input())
for i in range(Q):
    b, c = map(int, input().split())
    ans += c * n[b] - b * n[b]
    print(ans)
    n[c] += n[b]
    n[b] = 0


Measured memory_bytes: 84016
//g++  7.4.0

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MINN -1e18
#define MAXN 3005
#define MOD 1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll N; cin>>N;
    ll arr[N][N];
    
    vector<ll> dp((1 << N),MINN);
    ll cost[1 << N];
    
    for(ll i=0;i<N;++i)
    {
        for(ll j=0;j<N;++j)
        {
            cin>>arr[i][j];
        }
    }
    
    for(ll mask=0;mask < (1 << N);++mask)
    {
        ll ans = 0;
        for(ll i=0;i<N;++i)
        {
            if(mask & (1 << i))
            {
                for(ll j=(i + 1);j<N;++j)
                {
                    if(mask & (1 << j))
                        ans += arr[i][j];
                }
            }
        }
        
        cost[mask] = ans;
        //cout<<mask<<" "<<cost[mask]<<endl;
    }
    

    
    dp[0] = 0;
    for(ll mask=1;mask < (1 << N);++mask)
    {
        ll submask = mask;
        while(submask)
        {
            ll rem = mask ^ submask;
            dp[mask] = max(dp[mask],dp[rem] + cost[submask]);
            
            submask = (submask - 1) & mask;
        }
    }
    
    cout<<dp[(1 << N) - 1]<<endl;
}

Measured memory_bytes: 4244
#pragma gcc optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i=(ll)(r);i<(ll)(n);++i)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define pb(n) push_back(n)
#define endl '\n'
#define debug(x) cout << #x << " = " << (x) << endl
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c
#define VIN(V) for(int ii = 0; ii < (V).size(); ii++) {cin >> (V).at(ii);}
#define OUT(n) cout << n << endl
#define OUT2(n1,n2) cout << n1 << " " << n2 << endl
#define OUT3(n1,n2,n3) cout << n1 << " " << n2 << " " << n3 << endl
#define VOUT(V) REP(ii,(V).size()){cout << (V)[ii] << " ";} cout<<endl;
#define VOUT2(V) REP(jj,(V).size()){VOUT(V[jj])}
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<vi > vvi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
ll n, m, k, ans, sum, cnt = 0; string s; char c;

int main(){
  cin.tie(0);ios::sync_with_stdio(false);
  IN(n);
  vi a(n);
  VIN(a);
  vi countar(n+1);
  FOR(i,0,n+1) countar[i]=0;
  vi ansv;

  RFOR(i,1,n+1) {
    cnt = 0;
    FOR(j,1,n/i+1) {
      //OUT3(i, j, countar[j]);
      if (countar[j*i] == 1) cnt++;
    }
    if (cnt%2==a[i-1]) {
      // nothing
    } else {
      countar[i] = 1;
      ansv.pb(i);
    }
    //VOUT(countar);
  }

  OUT(ansv.size());
  VOUT(ansv);
}


Measured memory_bytes: 5108
#include <iostream>
using namespace std;
int main(){
    int seven = 0, five = 0;
    for(int i = 0; i < 3; i++){
        int n; cin >> n;
        if(n == 7) seven++;
        if(n == 5) five++;
    }
    if(seven == 1 && five == 2) puts("YES");
    else puts("NO");
    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

template<typename T>
void p(T elem) {cout << elem << endl;}
template<typename T>
void ps(vector<T>& arr) { for(T e: arr) p(e); }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#else
#define debug(fmt, ...)
#endif

struct edge {
    int src;
    int dst;
    int coins;
};

#define INF ((1e+9)+1)

int main(void) {
    int vs, es, penalties;
    cin >> vs >> es >> penalties;
    vector<struct edge> edges(es);
    for(auto& e: edges) {
        int src, dst, coins;
        cin >> src >> dst >> coins;
        // inverse for bellman-ford
        e = (struct edge){src-1, dst-1, -(coins-penalties)};
    }

    vector<int> coins(vs, INF);
    coins[0] = 0;
    // Bellman Ford algorithm
    for(int i = 0; i < vs-1; i++) {
        for(int j = 0; j < es; j++) {
            struct edge e = edges[j];
            if(coins[e.src] == INF) continue;
            int nnew = coins[e.src] + e.coins;
            coins[e.dst] = min(nnew, coins[e.dst]);
        }
    }
    // ans: -coins[vs-1]
    int ans = max(0, -coins[vs-1]);
    debug("ans: %d\n", ans);

    // sanity check
    vector<char> check_negative(vs);
    for(int i = 0; i < vs; i++) {
        for(auto& e: edges) {
            if(coins[e.src] == INF) continue;
            int nnew = coins[e.src] + e.coins;
            if(nnew < coins[e.dst]) {
                check_negative[e.dst] = 1;
                coins[e.dst] = nnew;
            }
            if(check_negative[e.src]) {
                check_negative[e.dst] = 1;
            }
        }
    }
    cout << (check_negative[vs-1] ? -1 : ans) << endl;
    return 0;
}

Measured memory_bytes: 3668
#include <stdio.h>

int main(void)
{
  char c;
  scanf("%c", &c);
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') printf("vowel\n");
  else printf("consonant\n");

  return (0);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int f[101][100001],a[100001];
int main()
{
	int i,n,j,k;
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	f[0][0]=1;
	for(i=0;i<=k;i++)
		f[0][i]=1;
	for(i=1;i<=n;i++)
	{
		for(j=0;j<=k;j++)
		{
			f[i][j]=f[i-1][j];
			if(j-a[i]-1>=0)
				f[i][j]=(f[i][j]+1000000007-f[i-1][j-a[i]-1])%1000000007;
		}
		for(j=1;j<=k;j++)
			f[i][j]=(f[i][j]+f[i][j-1])%1000000007;
	}
	printf("%d",(f[n][k]-f[n][k-1]+1000000007)%1000000007);
	return 0;
}

Measured memory_bytes: 39680
#include<iostream>
using namespace std;
int n,A[20];
int solve(int i,int m){
    if(m==0) return true;
    if(i>=n) return false;
    int res=solve(i+1,m) || solve(i+1,m-A[i]);
    return res;
}
int main(){
    int q,M;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
    cin>>q;
    for(int i=0;i<q;i++){
        cin>>M;
        if(solve(0,M)) cout<<"yes"<<endl;
        else cout<<"no"<<endl;
    }
    return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()

int main() {
    int a;
    cin >> a;
    cout << a + pow(a, 2) + pow(a, 3) << endl;
}

Measured memory_bytes: 4280
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>
 
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
 
string S;
ll N,M;
 
 
 
int main(){
    cin >> N >> M;
    if(N<M){
        for(int i=0;i<M;i++) cout << N;
    }else{
        for(int i=0;i<N;i++) cout << M;
    }
    cout << endl;
}


Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
union_find = Array(0..n)
rank = Array.new(n + 1, 0)

def union_find.root(idx)
  self[idx] == idx ? idx : (self[idx] = root(self[idx]))
end

m.times do
  a, b = gets.split.map { |e| union_find.root(e.to_i) }
  next if a == b

  if rank[a] > rank[b]
    union_find[b] = a
  else
    union_find[a] = b
    rank[b] += 1 if rank[a] == rank[b]
  end
end

h = {}
union_find.each { |e| h[union_find.root(e)] = 1 }

puts h.size - 2


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

#define all(v)			((v).begin()), ((v).end())
#define SIZE(v)			((int)((v).size()))
#define LOG(x)			log((double)x)
#define TOLOWER(x)          transform(all(x),x.begin(),::tolower)
#define TOUPPER(x)          transform(all(x),x.begin(),::toupper)
#define ROUND(x,m)			(round((double)x/m)*m)
#define DIGITS(x)			(floor(log10((double)x))+1)
#define READSTR(x)			getline(cin,x)
#define sort_g(a,b)              sort(a, b, greater<int>());
#define IOS() ios_base::sync_with_stdio(0);cin.tie(NULL);
#define REP(i, n) for (int i = 0; i < n; i++)
#define FILE_INPUT() 	freopen( "input.txt", "r", stdin)
#define FILE_OUTPUT()   freopen( "output.txt", "w", stdout)
#define PI 3.14159265


typedef long long ll;

bool myCmp(pair<int,int> &p1 , pair<int,int>&p2)
{
    return p1.first > p2.first;
}
unsigned long long
choose(unsigned long long n, unsigned long long k) {
    if (k > n) {
        return 0;
    }
    unsigned long long r = 1;
    for (unsigned long long d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}
int toInt(string str)
{
    int num;
    std::istringstream iss(str); //put string in input stream
    iss >> num; return num; //read from stream as integer
}
ll  OO = 10e9;
const int MAXN = 10e6;
ll ans = 0;
bool noPrime[MAXN] = {0};
void seive(int cnt)
{
    noPrime[0] = noPrime[1] = true;
    for(int i =  2 ;  i*i < cnt ; i++)
    {
        if(!noPrime[i]){
            for(int j = i*i ; j < cnt ; j+=i)
            {
                noPrime[j] = true;
            }
        }
    }
}
bool isPrime(ll x)
{
    if(x%2 == 0) return false;
    ll tmp = sqrt(x) ;
    for(int i=3; i<=tmp; i+=2)
    {
        if(x%i == 0)
            return false;
    }
    return true;
}
set<ll> fact,comFact;
int main() {
    IOS();
    ll A,B;
    seive(MAXN);
    cin>>A>>B;
    ll tmp = sqrt(A);
    for(ll i = 1 ; i <=tmp ; ++i)
    {
        if((A%i == 0)){
            fact.insert(i);
            fact.insert(A/i);
        }
    }
    for(auto it = fact.begin() ; it!=fact.end() ;it++)
    {
        if(B%(*it) == 0)
            comFact.insert(*it);
    }

    for(auto it = comFact.begin() ; it!=comFact.end() ;it++)
    {
        if(*it >= MAXN)
        {
            ans+=isPrime(*it);
        }
        else
        {
            ans+= (!noPrime[*it]);
        }
    }
    cout<<ans+1<<endl;
    return 0;
}


Measured memory_bytes: 10624
<?php
fscanf(STDIN,"%d %d",$katana,$hp); // 1 2
for( $i=1 ; $i<=$katana ; $i++){
    fscanf(STDIN,"%d %d",$cut[$i],$throw[$i]);
}

//切るダメージ
$attackCut = max($cut);

//echo "Cut:".$attackCut."\n";
rsort($throw);
//print_r($throw);

//攻撃回数
$count = 0;
//終わりから逆に考える
//ダメージが大きい投げから考える
foreach ($throw as $attackThrow)
{
    //投げが切るよりも上回ると、切るに移る
    if ( $attackThrow<$attackCut )
    {
        break;
    }
    //魔物の$hpを$attackThrow分減らす
    $count++;
    //echo $count.":".$attackThrow."\n";
    $hp -= $attackThrow;
    //魔物の$hpが0以下だと、一旦切るに移る
    if ( $hp<=0 )
    {
        break;
    }
}

//切る
/*
//魔物の$hpが0より大きいと切る
while( $hp>0 )
{
    //魔物の$hpを$attackCut分減らす
    $count++;
    //echo $count.":".$attackCut."\n";
    $hp -= $attackCut;
}
*/

//$hpが残っている場合、切るダメージで割り算して計算
if ( $hp>0 )
{
    $count += ceil($hp / $attackCut);
}

echo $count."\n";
?>

Measured memory_bytes: 33396
n, d = map(int,input().split())
x = [0]*n
y = [0]*n
for i in range(n):
    x[i],y[i] = map(int,input().split())

d2 = d**2

ans = 0

for i in range(n):
    if x[i]**2 + y[i]**2 <= d2:
        ans+=1

print(ans)

Measured memory_bytes: 24640
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(20);
    ll n; cin >> n;
    for (ll i = 1; i <= n; i++) {
        ll res = 0;
        for (ll x = 1; x * x < i; x++) {
            for (ll y = 1; x * x + y * y + x * y < i; y++) {
                for (ll z = 1; x * x + y * y + z * z + x * y + y * z + x * z <= i; z++) {
                    res += (x * x + y * y + z * z + x * y + y * z + x * z == i);
                }
            }
        }
        cout << res << "\n";
    }
}


Measured memory_bytes: 3536
N = int(input())
A = list(map(int,input().split()))

dic = {}
for i in range(N):
    data = A[i]
    if data in dic:  dic[data] += 1
    else:  dic[data] = 1
        
ans = 0
for i in dic:
    if dic[i] > i:  ans += dic[i] - i
    elif dic[i] < i:  ans += dic[i]
print(ans)

Measured memory_bytes: 98932
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main(){
    long long int a,b,c,d;
    cin >> a >> b >> c >> d;
    long long int q1 = a*c;
    long long int q2 = a * d;
    long long int q3 = b * c;
    long long int q4 = b* d;
    cout << max(q1,max(q2,max(q3,q4))) << endl;
    
}


Measured memory_bytes: 3628
package main

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

func main() {
  input := Input{bufio.NewReaderSize(os.Stdin,100)}
  n,h,w := input.NextInts()
  es := make(Edges,n)
  for i:=0;i<n;i++ {
    r,c,a := input.NextInts()
    es[i] = Edge{r-1,h+c-1,int64(a)}
  }
  sort.Sort(sort.Reverse(es))
  uf := NewUnionFind(h+w)
  ans := int64(0)
  for i:=0;i<n;i++ {
    fm,to := es[i].fm,es[i].to
    if uf.Same(fm,to) {
      if uf.Count(fm) >= uf.Size(fm) { continue }
    } else {
      if uf.Count(fm)+uf.Count(to)+1 > uf.Size(fm)+uf.Size(to) { continue }
    }
    uf.Unite(fm,to)
    ans += es[i].c
  }
  fmt.Println(ans)
}

type Edge struct { fm,to int;c int64 }
type Edges []Edge
type Graph [][]Edge
func(e Edges) Len() int { return len(e) }
func(e Edges) Swap(i,j int) { e[i],e[j] = e[j],e[i] }
func(e Edges) Less(i,j int) bool { return e[i].c < e[j].c }
func(g Graph) AddEdge(fm int,e Edge) { g[fm] = append(g[fm],e) }
func(g Graph) Add(fm,to int,c int64) { g.AddEdge(fm,Edge{fm,to,c}) }

type UnionFind struct { par,rank,size,cnt []int }
func NewUnionFind(n int) UnionFind {
  par := make([]int,n)
  rank := make([]int,n)
  size := make([]int,n)
  cnt := make([]int,n)
  for i:=0;i<n;i++ { par[i],size[i] = i,1 }
  return UnionFind{par,rank,size,cnt}
}
func(u UnionFind) Find(i int) int {
  if u.par[i] == i { return i }
  u.par[i] = u.Find(u.par[i])
  return u.par[i]
}
func(u UnionFind) Same(i,j int) bool { return u.Find(i) == u.Find(j) }
func(u UnionFind) Unite(i,j int) {
  i,j = u.Find(i),u.Find(j)
  if i == j { u.cnt[i]++;return }
  if u.rank[i] < u.rank[j] {
    u.par[i] = j
    u.size[j] += u.size[i]
    u.cnt[j] += u.cnt[i]+1
  } else {
    u.par[j] = i
    u.size[i] += u.size[j]
    u.cnt[i] += u.cnt[j]+1
    if u.rank[i] == u.rank[j] { u.rank[i]++ }
  }
}
func(u UnionFind) Size(i int) int { return u.size[u.Find(i)] }
func(u UnionFind) Count(i int) int { return u.cnt[u.Find(i)] }

type Input struct { reader *bufio.Reader }
func(i *Input) NextLine() string {
  var buffer []byte
  for {
    line,isPrefix,err := i.reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func(i *Input) NextInts() (int,int,int) {
  s := strings.Fields(i.NextLine())
  x,_ := strconv.Atoi(s[0])
  y,_ := strconv.Atoi(s[1])
  z,_ := strconv.Atoi(s[2])
  return x,y,z
}

Measured memory_bytes: 11904
@{$_ x3}=1for A..D;
for$i(1..<>-1){
	for$j(@_=glob'{A,B,C,D}'x3){
		(${$j=~/./;$'.$_}[$i]+="$j$_"!~/ABC|A.*C.*B|CAB/*$$j[$i-1])%=$%=1e9+7for A..D
	}
}
($\+=$$_[-1])%=$%for@_;print


Measured memory_bytes: 1024
//============================================================================
// Name        : hoba.cpp :)
// Author      : (O_O Diab) (Why_not) (el 3AQ)
// Version     :
// Copyright   : please, Don't touch me :(
// Description : problem in C++
// MAIN IDEA   : combinatorics NCR
//============================================================================
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define rw freopen("graphs_as_a_service.txt","r",stdin),freopen("output.txt","w",stdout);
#define pb push_back
#define F first
#define S second
#define pf push_front
#define lp(i,a,b) for (int i=a;i<=(int)b;++i)
#define lp2(i,a,b) for (int i=a;i>=b;--i)
#define f(x) return cout<<x<<"\n",0
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define p(x) cout<<#x<<" = { "<<x<<" } \n"
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define rep(i,a) lp(i,0,a-1)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define EPS 1e-6
// to convert string to number use int a = stoi(string);
// to convert number to string use string s = to_string(int);
#define FAST ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define clr(c,x) memset(c,x,sizeof(c));
using namespace __gnu_pbds;
using namespace std;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const int dx[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int N = 3e2 + 3, mod = (int) 1e9 + 7, INF = 0x3f3f3f3f;
int main() {
#ifdef ONLINE_JUDGE
	FAST
#endif
	int n, k;
	cin >> n >> k;
	if (!k)
		f(1LL * n * n);
	ll ans = 0;
	lp(i,k+1,n)
	{
		ans += (i - k);
		ans += (n / i - 1) * (i - k);
		int z = (n % i) - (k - 1);
		ans += max(0, z);
	}
	f(ans);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>


int main(){

  int l,n,m,i,count;
  
  while(1){
    count = 0;
    scanf("%d",&l);
    if ( l == 0)
      break;
  
    for(i = 0; i < 12; i++){
      scanf("%d %d",&m,&n);
      l = l - (m - n);
      if(l >0)
	count++;
	  }    
    if(count >= 11&& l > 0)
      printf("NA\n");
    else
      printf("%d\n",count+1);
  }
  return 0;
}

Measured memory_bytes: 0
r=[]
for i in range(3):
  a,b=map(int,input().split())
  r.append(a);r.append(b)
print("YES" if r.count(1) <=2 and r.count(2) <=2 and r.count(3)<=2 and r.count(4) <=2 else "NO")


Measured memory_bytes: 2940
#include<stdio.h>
#include<math.h>
int main(){
  int n,i,j,ans=0,tmp[1000000]={0};
  while(1){
    if(scanf("%d",&n) == EOF) break;
    double a = sqrt(n);
    for(i=2;i<=a;i++){
      for(j=i*2;j<=n;j+=i){
	tmp[j] = 1;
      }
    }
    ans = 0;
    for(i=2;i<=n;i++){
      if(tmp[i] == 0){
	ans++;
      }
    }
    printf("%d\n",ans);
  }
  return 0;
}
      

Measured memory_bytes: 4508
open System

let rec _gcd a b = if a % b = 0 then b else _gcd b (a % b)

let gcd a b c = _gcd a b |> _gcd c

[<EntryPoint>]
let main argv =
    let K = Console.ReadLine() |> int
    let ans = seq {
        for a in 1 .. K do
            for b in 1 .. K do
                for c in 1 .. K -> gcd a b c
    }
    ans |> Seq.sum |> printfn "%d"
    0


Measured memory_bytes: 33000
import sys
from collections import deque, defaultdict
import copy
import bisect
sys.setrecursionlimit(10 ** 9)
import math
import heapq
from itertools import product, permutations,combinations
import fractions
from operator import itemgetter


import sys
def input():
	return sys.stdin.readline().strip()

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

if x <= (a**2)*b / 2:
	shita = math.degrees(math.atan(a*(b**2)/(2*x)))
else:
	shita = math.degrees(math.atan( 2*((a**2)*b - x)/(a**3) ))

print(shita)


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

int main(){
  int h, w;
  cin >> h >> w;
  char grid[h+1][w+1];
  char ans[h+1][w+1];
  for(int i=1; i<=h; i++){
    for(int j=1; j<=w; j++){
      cin >> grid[i][j];
      ans[i][j] = grid[i][j];
    }
  }

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

  for(int i=1; i<=h; i++){
    for(int j=1; j<=w; j++){
      if(grid[i][j]=='#') continue;

      char cnt=0;
      for(int k=0; k<8; k++){
        int nx=j+dx[k], ny=i+dy[k];
        if(1<=nx && nx<=w && 1<=ny && ny<=h){
          if(grid[ny][nx]=='#') cnt++;
        }
      }
      ans[i][j]=cnt+'0';
    }
  }

  //回答を出力
  for(int i=1; i<=h; i++){
    for(int j=1; j<=w; j++) cout << ans[i][j];
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import re
S=input()
T=input()
ans=10**1000

for i in range(len(S)-len(T)+1):
    score=0
    u=S[i:i+len(T)]
    for j in range(len(T)):
        if u[j]!=T[j]:
            score+=1
    ans=min(ans,score)
print(ans)

Measured memory_bytes: 9788
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <iomanip>

using namespace std;
#define LOCAL  1
#define UPLOAD 2
#define ll long long
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
template <class T = long long> T input(){T x;cin >> x;return x;}
template <class T> void output(T x){cout << x << endl;}
#define debug(x) cerr << #x<< ": " << x<< '\n';

unsigned long long d(unsigned long long N){
  unsigned digit=0;
  while(N!=0){
      N /= 10;
      digit++;
  }
  return digit;
}

int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
  int N = input();  
  vector<pair<int,int>> X;

  for(int i=0;i<N;i++){
    int x = input();
    int y = input();
    X.push_back({x,y});
  }

  float lengthSum = 0;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      float length = sqrt(pow(X[i].first - X[j].first, 2) + pow(X[i].second - X[j].second, 2));
      lengthSum += length;
    }
  }

  float ret = lengthSum * (2.0f/N);

  std::cout << std::setprecision(30) << ret << endl;

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <stack>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define MAX_T 1001
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912
const long double PI = acos(-1);
const ll DEP = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int GCD(int x,int y){
    return y ? GCD(y,x%y) : x;
}
int main(){
    int N; cin >> N;
    string s; cin >> s;
    map<char,int> mp;
    for(int i = 0; i < N; i++){
        mp[s[i]]++;
    }
    ll ans = 1;
    for(char t = 'a'; t <= 'z'; t++){
        ans *= mp[t]+1;
        ans %= MOD;
    }
    cout << ans -1 << endl;
}



Measured memory_bytes: 512
<?php
$w = trim(fgets(STDIN));
$week = [
	'SUN' => 0,
	'MON' => 1,
	'TUE' => 2,
	'WED' => 3,
	'THU' => 4,
	'FRI' => 5,
	'SAT' => 6,
];
print 7 - $week[$w];


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

#include <math.h>
#include <stdlib.h>


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

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

// const int INF = 1001001001;
// long long max => LLONG_MAX

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    char a, b; cin >> a >> b;
    if(a == 'H' && b == 'H') cout << "H" << endl;
    else if(a == 'D' && b == 'D') cout << "H" << endl;
    else cout << "D" << endl;

    return 0;
}


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

using namespace std;

int main(int argc, char *argv[]) {
    int N, M;
    cin >> N >> M;

    vector<int> arr(N + 100, 0);
    int L, R;
    for (int i = 0; i < M; i++) {
        cin >> L >> R;
        arr[L]++;
        arr[R+1]--;
    }

    for (int j = 1; j < arr.size(); j++) {
        if (j > 0) arr[j] += arr[j - 1];
    }

    int ans = 0;
    for (int k = 0; k < arr.size(); k++) {
        if (arr[k] == M) ans++;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace A_KEY2020
{
    class MainClass
    {

        static int[] s, a, b;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            a = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            b = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);

            int x = Max(s[0], a[0]);
            if (b[0] % x == 0)
            {
                WriteLine(b[0] / x);
            }
            else
            {
                WriteLine(b[0] / x + 1);
            }
        }
    }
}


Measured memory_bytes: 13268
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
int main()
{
    double a;
    scanf("%lf",&a);
    a=a/3;
    a=a*a*a;
    printf("%.12lf",a);
    return 0;
}


Measured memory_bytes: 256
K, A, B = map(int, input().split())
tmp = K - A + 1
ans1 = K + 1
if tmp % 2 == 0:
    print(max(ans1, A + tmp // 2 * (B - A)))
else:
    print(max(ans1, A + tmp // 2 * (B - A) + 1))


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

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

#define MOO(i, a, b) for (int i=a; i<b; i++)
#define M00(i, a) for (int i=0; i<a; i++)
#define MOOd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define M00d(i,a) for (int i = (a)-1; i >= 0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;
#define dbg(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _<< " _ " <<

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ld,ld> pd;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;

//a has higher priority than b?
bool compareF(vi a, vi b) {
	return a[0] + a[1] < b[0] + b[1];
}

int main() { FAST
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	int n;
	cin >> n;
	vector<vi> boxes;
	M00(i, n) {
		//weight, strength, val
		int w, s, v;
		vi temp(3);
		cin >> temp[0] >> temp[1] >> temp[2];
		boxes.pb(temp);
	}
	sort(all(boxes), compareF);
	//DP[i] stores best value with weight i
	vll DP(20010, 0);
	M00(i, n) {
		int w = boxes[i][0];
		int s = boxes[i][1];
		int v = boxes[i][2];
		for(int j = 20000; j>= 1; j--) {
			if(0 <= j - w && j - w <= s) DP[j] = max(DP[j], v + DP[j-w]);
		}
	}
	ll ans = 0;
	M00(i, 20001) ans = max(ans, DP[i]);
	finish(ans);
}


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

typedef long long ll;

map<ll, ll> dp;
ll dv[3] = { 2, 3, 5 }, py[3], a, b, c, d;

ll solve(ll now)
{
	if (dp.count(now))
		return dp[now];

	ll ans = 1e18, i;

	if (ans / d >= now)
		ans = min(ans, now * d);

	for (i = 0; i < 3; i++)
	{
		ans = min(ans, now % dv[i] * d + solve(now / dv[i]) + py[i]);
		if (now / dv[i] + 1 < now)
			ans = min(ans, (dv[i] - now % dv[i]) * d + solve(now / dv[i] + 1) + py[i]);
	}

	return dp[now] = ans;
}

int main(void)
{
	ll t;

	scanf("%lld" ,&t);
	while (t--)
	{
		ll n;

		scanf("%lld %lld %lld %lld %lld" ,&n, &a, &b, &c, &d);

		dp.clear();
		dp[0] = 0;
		py[0] = a, py[1] = b, py[2] = c;

		printf("%lld\n" ,solve(n));
	}
	return 0;
}

Measured memory_bytes: 4376
#include <stdio.h>

int main(void){
  int n, sum = 0;
  scanf("%d", &n);
  int v[n], c[n];
  for(int i = 0; i < n; i++) scanf("%d", &v[i]);
  for(int i = 0; i < n; i++) scanf("%d", &c[i]);
  
  for(int i= 0; i < n; i++){
    if(v[i] > c[i]) sum += v[i] - c[i];
  }
  printf("%d", sum);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
typedef long long ll;
using namespace std;
const int inf=1e+6;
//ダイクストラ法の計算量はO(NlogV)だぞ！！ O(NV)じゃないんだぞ！！
int main(void){
    int n,m;cin>>n>>m;
    vector<vector<int>> t(n);
    rep(i,m){
        int u,v;cin>>u>>v;u--,v--;
        t[u].push_back(v);
    }
    int s,T;cin>>s>>T;s--;T--;
    vector<vector<ll>> p(n,vector<ll>(3,inf));
    queue<pair<int,int>> que;
    que.push({s,0});
    p[s][0]=0;//3で割った余り どれにもなれるなら3を入れる
    while(que.size()){
        int x=que.front().first,now=que.front().second; que.pop();
        ll y=p[x][now];
        rep(i,t[x].size()){
            int z=t[x][i];
            if(p[z][(now+1)%3]!=inf)continue;
            p[z][(now+1)%3]=y+1;
            que.push({z,(now+1)%3});
        }
    }
    ll dis=p[T][0];
    if(dis==inf){
        cout<<-1<<endl;
        return 0;
    }else{
        ll res=(dis+2)/3;
        cout<<res<<endl;
        return 0;
    }
}


Measured memory_bytes: 11136
#include<cstdio>
#define MAX 10000
#define NIL -1

struct Node { int parent, left, right; };

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d) {
  if ( u == NIL ) return;
  D[u] = d;
  setDepth(T[u].left, d + 1);
  setDepth(T[u].right, d + 1);
}

int setHeight(int u) {
  int h1 = 0, h2 = 0;
  if ( T[u].left != NIL )
    h1 = setHeight(T[u].left) + 1;
  if ( T[u].right != NIL )
    h2 = setHeight(T[u].right) + 1;
  return H[u] = ( h1 > h2 ? h1 : h2 );
}

int getSibling(int u) {
  if ( T[u].parent == NIL ) return NIL;
  if ( T[T[u].parent].left != u && T[T[u].parent].left != NIL )
    return T[T[u].parent].left;
  if ( T[T[u].parent].right != u && T[T[u].parent].right != NIL )
    return T[T[u].parent].right;
  return NIL;
}

void print(int u) {
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].parent);
  printf("sibling = %d, ", getSibling(u));
  int deg = 0;
  if ( T[u].left != NIL ) deg++;
  if ( T[u].right != NIL ) deg++;
  printf("degree = %d, ", deg);
  printf("depth = %d, ", D[u]);
  printf("height = %d, ", H[u]);

  if ( T[u].parent == NIL ) {
    printf("root\n");
  } else if ( T[u].left == NIL && T[u].right == NIL ) {
    printf("leaf\n");
  } else {
    printf("internal node\n");
  }
}

int main() {
  int v, l, r, root = 0;
  scanf("%d", &n);
  
  for ( int i = 0; i < n; i++ ) T[i].parent = NIL;

  for ( int i = 0; i < n; i++ ) {
    scanf("%d %d %d", &v, &l, &r);
    T[v].left = l;
    T[v].right = r;
    if ( l != NIL ) T[l].parent = v;
    if ( r != NIL ) T[r].parent = v;
  }

  for ( int i = 0; i < n; i++ ) if ( T[i].parent == NIL ) root = i;

  setDepth(root, 0);
  setHeight(root);

  for ( int i = 0; i < n; i++ ) print(i);

  return 0;
}


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

using namespace std;
typedef long long ll;
#define MOD 1000000007

int main()
{

  ll n;
  cin >> n;

  ll d = n % 10;
  if (d == 2 || d == 4 || d == 5 || d == 7 || d == 9)
  {
    cout << "hon" << endl;
  }
  else if (d == 0 || d == 1 || d == 6 || d == 8)
  {
    cout << "pon" << endl;
  }
  else
  {
    cout << "bon" << endl;
  }

  return 0;
}


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

using ll = long long;
const ll MOD = (ll)1e9+7;

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

  ll A[N];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  ll comSum[N];
  comSum[N-1]=0;
  for (ll i = N-2; i >= 0; i--) {
    comSum[i] = comSum[i+1]+A[i+1];
    comSum[i] %= MOD;
  }

  ll ans = 0;
  for (int i = 0; i < N-1; i++) {
    ans += A[i]*comSum[i]%MOD;
    ans %= MOD;
  }

  cout << ans << endl;
  return 0;
}

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

#define llint long long int
#define pb push_back

using namespace std;

int main(){
  int n;
  cin >> n;
  int a;
  int sum = 0, mx = 0;
  for(int i = 0; i < n; i++){
    cin >> a;
    sum += a;
    if(a > mx)
      mx = a;
  }
  sum -= mx;
  if(sum > mx)
    cout << "Yes";
  else cout << "No";
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int day, numberOfTypes, bestShowy = 0;
		
		day = sc.nextInt();
		numberOfTypes = sc.nextInt();
		
		int temperature [] = new int [day];
		int clothesInfo [][] = new int [numberOfTypes][3];
		
		for (int i = 0; i < day; i++) {
			temperature[i] = sc.nextInt();
		}
		
		for (int i = 0; i < numberOfTypes; i++) {
			for (int j = 0; j < 3; j++) {
				clothesInfo[i][j] = sc.nextInt();
			}
		}

		int showy[][] = new int [day][numberOfTypes];
		
		for (int i = 0; i < day; i++) {
			for (int j = 0; j < numberOfTypes; j++) {
				if (clothesInfo[j][0] <= temperature[i] && clothesInfo[j][1] >= temperature[i]) {
					showy[i][j] = 0;
				}else {
					showy[i][j] = -1;
				}
			}
		}
		
		for (int i = 1; i < day; i++) {
			for (int j = 0; j < numberOfTypes; j++) {
				if (showy[i][j] == 0) {
					for (int k = 0; k < numberOfTypes; k++) {
						if (showy[i - 1][k] != -1) {
							showy[i][j] = Math.max(showy[i][j], showy[i - 1][k] + Math.abs(clothesInfo[k][2] - clothesInfo[j][2]));
						}
					}
				}
			}
		}

		for (int p = 0; p < numberOfTypes; p++) {
			bestShowy = Math.max(bestShowy, showy[day - 1][p]);
		}
		
		System.out.println(bestShowy);
	}
	
}

Measured memory_bytes: 21784
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=1e3+5;
const ll inf=1e18;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    ll t;
    long double ans = 1;
    for (int i = 0; i < n; i++)
    {
        cin >> t;
        if (ans != -1)
            ans *= t;
        if (ans > 1000000000000000000 || ans < 0)
            ans = -1;
        if (t == 0)
            ans = 0;
    }
    cout << (ll)ans;
    return 0;
}


Measured memory_bytes: 3612
//                             In The Name Of Allah
#include <bits/stdc++.h>
#define ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long long 
using namespace std; 

const long long N = 5e3, OO = 1e18, M = 1e9 + 7, M2 = 998244353, sq = 31622, lg = 23;
typedef pair <int, int> pii;
int dp[N][N], a[N], b[N], f[N];

int32_t main() {
	use_fast;
	int n, m;
	cin >> n >> m;
	for(int i = 1; i <= m; i++) {
		cin >> a[i] >> b[i];
		int t = 0, bt = 0;
		for(int j = 0; j < b[i]; j++) {
			int x;
			cin >> x;
			x--;
			while(t < x)
				bt *= 2, t++;
			bt++;
		}
		while(t < n - 1)
			t++, bt *= 2;
		f[i] = bt;
	}
	memset(dp, 43, sizeof(dp));
	int t = 1 << n;
	dp[0][0] = 0;
	for(int i = 1; i <= m; i++) {
		for(int j = 0; j < t; j++) {
			int r = f[i] & j;
			r = r ^ j;
			dp[i][j] = min(dp[i - 1][j], dp[i - 1][r] + a[i]);
		}
	}
	if(dp[m][t - 1] == 3110627432037296939)
		return cout << -1, 0;
	cout << dp[m][t - 1] << endl;
	return 0;
}
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- ... 
*/

Measured memory_bytes: 195584
#include <iostream>

using namespace std;

string s;
int ans;

int main()
{
    cin >> s;
    ans = 1;
    for (int i = 0; i < s.length(); i++)
    {
        if (i % 2 == 0)
        {
            if (s[i] == 'L')
            {
                ans = 0;
                break;
            }
        }
        else
        {
            if (s[i] == 'R')
            {
                ans = 0;
                break;
            }
        }
    }
    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
sl = []
for i in range(m):
    s = list(map(int, input().split()))
    del s[0]
    sl.append(s)
p = list(map(int, input().split()))

ans = 0
for i in range(1 << n):
    ok = True
    for j in range(m):
        cnt = 0
        for k in range(len(sl[j])):
            if (i >> sl[j][k] - 1)%2 == 0:
                cnt += 1
        if cnt%2 != p[j]:
            ok = False
            break
    if ok:
        ans += 1
print(ans)

Measured memory_bytes: 71024
#include <stdio.h>

int main(int argc,char* argv[]){
  int d;
  int i,sum;
  
  while(scanf("%d",&d) != EOF){
    sum = 0;
    for(i = 1;(i*d) < 600;i++){
      sum += d * (i*d) * (i*d); 
    }

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

Measured memory_bytes: 0
#include <iostream>

using namespace std;

void parallelism(double, double, double, double, double, double, double, double);

int main() {

	double x1, y1, x2, y2, x3, y3, x4, y4, n;

	cin >> n;

	while(n!=0) {
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		parallelism(x1, y1, x2, y2, x3, y3, x4, y4);
		n--;
	}

	return 0;

}

void parallelism(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) {

	double x12, y12, x34, y34;

	x12=x2-x1;
	y12=y2-y1;
	x34=x3-x4;
	y34=y3-y4;

	if(x12*y34==y12*x34)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

}

Measured memory_bytes: 0
import java.io.IOException;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		n = scanner.nextInt();
		int q = scanner.nextInt();
		int[] st = new int[n];
		for (int i = 0; i < n; i++)
			st[i] = scanner.nextInt();
		int[] s = Arrays.copyOf(st, n);
		Arrays.sort(s);
		PriorityQueue<Integer> list = new PriorityQueue<Integer>();
		while (q-- > 0) {
			char query = scanner.next().charAt(0);
			int x = scanner.nextInt();
			if (query == 'A') {
				list.add(st[x - 1]);
			} else if (query == 'R') {
				list.remove(st[x - 1]);
			} else {
				int r = INF;
				int l = 0;
				while (r != l) {
					int mid = (r + l) / 2;
					int pre = 0;
					int BAN = 0;
					TreeSet<Integer> set = new TreeSet<Integer>();
					set.addAll(list);
					for (int i:set) {
						int p = lower(s, i - mid);
						BAN += Math.max(p - pre, 0);
						pre = upper(s, i);
					}
					BAN += n - pre;
					if (BAN <= x)
						r = mid;
					else
						l = mid + 1;
				}
				System.out.println(l != INF ? l : "NA");
			}
		}
	}

	private int lower(int[] s, int i) {
		int p = Arrays.binarySearch(s, i);
		if (p < 0) {
			p = p * -1 - 1;
		} else {
			for (int j = p - 1; j >= 0; j--) {
				if (s[j] != i)
					break;
				p--;
			}
		}
		return p;
	}

	private int upper(int[] s, int i) {
		int pre = Arrays.binarySearch(s, i);
		for (int j = pre + 1; j < n; j++) {
			if (s[j] != i)
				break;
			pre++;
		}

		return pre + 1;
	}

	int INF = 1000000001;
	int n;
}

Measured memory_bytes: 298256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
	public static void main(String[] args) {
		try {
			StringBuilder answer = new StringBuilder();
			String lb = System.getProperty("line.separator");
			long sum = 0;
			BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
			String[] nm = input.readLine().split(" ");
			int n = Integer.parseInt(nm[0]);
			int m = Integer.parseInt(nm[1]);
			ArrayList<String[]> matrix = new ArrayList<String[]>(n);
			for (int i = 0; i < n; i++) {
				matrix.add(input.readLine().split(" "));
			}
			String[] vector = new String[m];
			for (int i = 0; i < m; i++) {
				vector[i] = input.readLine();
			}
			for (int i = 0; i < n; i++) {
				String[] column = matrix.remove(0);
				sum = 0;
				for (int j = 0; j < m; j++) {
					sum += Integer.parseInt(column[j]) * Integer.parseInt(vector[j]);
				}
				answer.append(String.valueOf(sum)).append(lb);
			}
			System.out.print(answer.toString());
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}
}

Measured memory_bytes: 24036
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vc = vector<char>;
using vvc = vector<vector<char>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using tll = tuple<ll, ll, ll>;

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

    int a[M], b[M];

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

    vi p(N);

    for (int i = 0; i < N; i++)
    {
        p[i] = i;
    }

    vvi graph(N);

    for (int i = 0; i < M; i++)
    {
        graph[a[i] - 1].push_back(b[i] - 1);
        graph[b[i] - 1].push_back(a[i] - 1);
    }

    int ans = 0;

    do
    {
        if (p[0] != 0)
            break;

        bool br = false;

        for (int i = 0; i < N - 1; i++)
        {
            bool path = false;

            for (int j : graph[p[i]])
            {
                if (j == p[i + 1])
                    path = true;
            }

            if (!path)
            {
                br = true;
                break;
            }
        }

        if (!br)
            ans++;
    } while (next_permutation(p.begin(), p.end()));

    cout << ans << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,M=MI()
    L=[0]*N
    L[0]=1
    cnt=[1]*N
    for i in range(M):
        x,y=MI()
        x-=1
        y-=1
        if L[x]==1:
            L[y]=1
            if cnt[x]==1:
                L[x]=0
                flag=0
        cnt[x]-=1
        cnt[y]+=1
                
    print(sum(L))
        

main()


Measured memory_bytes: 75304
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2326>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

/*
 1-index
 
 add : x に valを加算
 sum : [1,x] の総和を出力
 */
ll MOD;
struct BIT {
    ll N;
    vector<ll> bit;
    BIT(ll N):N(N) {
        /* BITは[1..N]で扱う */
        bit.resize(N + 1, 0);
    }
    
    void add(int x, ll val){
        val %=MOD;
        while (x <= N) {
            (bit[x] += val)%=MOD;
            x += x & -x;
        }
    }
    
    ll sum(int x){
        ll ret = 0;
        while (x) {
            (ret += bit[x])%=MOD;
            x &= (x - 1);
        }
        return (ret);
    }
};
ll solve(ll A,ll B,ll P){
    ll res = 0;
    MOD = P;
    vector<string> S(B-A+1);
    for(ll x = A; x <= B;x++) S[x-A] = to_string(x);
    sort(S.begin(),S.end());
    BIT bit(B-A+2);
    for(int i = 0; i < S.size(); i++){
        ll x = atoll(S[i].c_str()) - (A-1);
        ll Sum = 0;
        if(x!=1) Sum = bit.sum(x-1);
        bit.add(x,Sum+1);
    }
    
    res = bit.sum(B-A+2);
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    ll A,B,P;
    while(cin>>A>>B>>P,A|B|P){
        cout << solve(A,B,P) << endl;
    }
    return 0;
}



Measured memory_bytes: 9288
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
const int  N = 2e5 + 314;
void foo(){
    int n;
    cin>>n;
    bool ok=1;
    for(int i = 0; i < n; i++){
        int x;
        cin>>x;
        if(x%2==0){
            if(x%3!=0&&x%5!=0)ok=0;
        }
    }   
    if(ok)cout<<"APPROVED";
    else cout<<"DENIED";
}
int main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)foo();
}

Measured memory_bytes: 256
gets
xs = gets.chomp.split.map(&:to_i)

count = 0
state = :none
before_x = :none
xs.each do |x|
    if state == :none
        state = :mono_decreasing_and_mono_increasing
        count = count + 1
    elsif state == :mono_decreasing_and_mono_increasing
        if x > before_x
            state = :mono_increasing
        elsif x < before_x
            state = :mono_decreasing
        else
            state = :mono_decreasing_and_mono_increasing
        end
    elsif state == :mono_increasing
        if x < before_x
            state = :mono_decreasing_and_mono_increasing
            count = count + 1
        end
    elsif state == :mono_decreasing
        if x > before_x
            state = :mono_decreasing_and_mono_increasing
            count = count + 1
        end
    end

    before_x = x
end

puts count

Measured memory_bytes: 9484