akhauriyash/Code-Regression huggingface dataset:
import sys

input = sys.stdin.readline

def main():
    ans = 'Yes'
    N = int(input())
    wl = []
    wl.append(input().rstrip('\n'))
    for i in range(1,N):
        wl.append(input().rstrip('\n'))
        if wl[i-1][-1] != wl[i][0]:
            ans = 'No'
            break
    if len(wl) != len(set(wl)):
        ans = 'No'
    print(ans)

if __name__ == '__main__':
    main()

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

#define F first 
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 2 * N;

int n;
int h[N], e[M], ne[M], idx;
int fd[N], sd[N];

void add(int a, int b)
{
	e[idx] = b, ne[idx] = h[a], h[a] = idx ++ ;
}

void dfs(int u, int d[], int dist)
{
	d[u] = dist;
	for (int i = h[u]; ~i; i = ne[i])
	{
		int j = e[i];
		if (d[j] != -1) continue;
		
		dfs(j, d, dist + 1);
	}
}

int main()
{
	memset(h, -1, sizeof h);
	scanf("%d", &n);
	
	for (int i = 0; i < n - 1; i ++ )
	{
		int a, b;
		scanf("%d%d", &a, &b);
		add(a, b), add(b, a);
	}
	
	memset(fd, -1, sizeof fd);
	memset(sd, -1, sizeof sd);
	dfs(1, fd, 0);
	dfs(n, sd, 0);
	
	int f = 0, s = 0;
	for (int i = 1; i <= n; i ++ )
		if (fd[i] <= sd[i]) f ++ ;
		else s ++ ;
		
	if (f > s) puts("Fennec");
	else puts("Snuke");
    return 0;
}

Measured memory_bytes: 11068
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    long N = in.nextLong();
    for(long i = (long) Math.sqrt(N); i >= 0; i--) {
      if(N % i == 0) {
        System.out.println(i + N / i - 2);
        return;
      }
    }
  }
}

Measured memory_bytes: 23252
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//

        string A, B;
        cin >> A >> B;

        sort(A.begin(), A.end());
        sort(B.begin(), B.end(), greater<ll>());
        if (A < B)
        {
                cout << "Yes" << endl;
        }
        else
        {
                cout << "No" << endl;
        }

        return 0;
}


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

using namespace std;

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

	vector<int> S(n + 1);
	for (int i = 0; i < n; ++i)
		cin >> S[i];

	int q;
	cin >> q;
	vector<int> T(q);
	for (int i = 0; i < T.size(); ++i)
		cin >> T[i];

	// Linear Search
	int count = 0;
	for (int j = 0; j < T.size(); ++j)
	{
		int i = 0;
		S[n] = T[j];
		while (S[i] != T[j])
			i++;
		if (i != n)
			count++;
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 1236
import sys

def main():
    def input(): return sys.stdin.readline().rstrip()
    N = int(input())
    A = list(map(int, input().split()))
    cnt = 0
    for i in range(N):
        if A[i] % 2 != 0:
            cnt += 1
    
    print('YES' if cnt % 2 == 0 else 'NO')
if __name__ == '__main__':
    main()

Measured memory_bytes: 14108
n,m = gets.chomp.split.map(&:to_i)
rs = m.times.map{gets.chomp.split.map(&:to_i)}
ans=[]
1.upto(n) do |i|
  cnt = 0
  rs.each {|r|cnt += r.count{|k| k == i}}
  ans.push(cnt)
end
puts ans


Measured memory_bytes: 1788
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
void log(A...)(A arg) { stderr.writeln(arg); }
int size(T)(in T s) { return cast(int)s.length; }

void main() {
    int N; readf("%d\n", &N);
    auto A = readln.chomp.split(" ").map!(to!int).array;
    sort(A);
    long ans = 0;
    for (int i = N; i < 3 * N; i += 2) {
        ans += A[i];
    }
    writeln(ans);
}


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

#define MOD (1000000000+7)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;
#define forf(i,a,b) for(int i = (a); i < (b); i++)
#define forr(i,a,b) for(int i = (a); i > (b); i--)
#define input(vec,N) for(int i = 0; i < (N); i++) cin >> vec[i];

// template starts
typedef long long int ll;

// template ends here

void solve(){
	// code starts from here
	ll x1,x2,x3,x4,x5;
	cin >> x1 >> x2 >> x3 >> x4 >> x5;
	if(x1 == 0) cout << 1 << endl;
	else if(x2 == 0) cout << 2 << endl;
	else if(x3 == 0) cout << 3 << endl;
	else if(x4 == 0) cout << 4 << endl;
	else if(x5 == 0) cout << 5 << endl;
}

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

	int T;
	T = 1;
	while(T--){
		solve();
	}

	return 0;
}


Measured memory_bytes: 3580
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>

using namespace std;

int main() {
	string s;
	cin >> s;
	cout << s[0] - '0' + s[1] - '0' + s[2] - '0' << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int sum(int num){
  int i=0;
  while(num>=1){
    i += num%10;
    num /= 10;
  }
  return i;
}

int main(void){
  int n, a, b, j, summ=0;
  scanf("%d %d %d", &n, &a, &b);
  for(j=1;j<=n;j++){
    if(sum(j)>=a && sum(j)<=b)
      summ += j;
  }
  printf("%d\n", summ);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i< (n) ; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main(){
 int n,m;
  //string s;
  cin >> n >> m;
  cout << (n-1)*(m-1) <<endl;
    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main()
{
     ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n,m;
    cin>>n>>m;
    int s[3]={9,9,9},f[3]={0};
    int a[5][2];
    for(int i=0;i<m;i++)
    {
    	cin>>a[i][0]>>a[i][1];
	}
	for(int i=0;i<m;i++)
    {
        for(int j=0;j<m;j++)
        {
        	if(a[i][0]==a[j][0]&&a[i][1]!=a[j][1]){
        		cout<<-1;
        		return 0;
			}
		}
	}
	 for(int i=0;i<m;i++)
    {
    	if(a[i][0]==1&&a[i][1]==0&&n>1) {
		cout<<-1;
		return 0; }
	}
	 for(int i=0;i<m;i++)
    {
    	if(a[i][1]<s[a[i][0]-1]||f[a[i][0]-1]==0)
    	{
		s[a[i][0]-1]=a[i][1];
		f[a[i][0]-1]+=1;
		}
	}
	if(f[0]==0&&n>1) {
	s[0]=1;
	f[0]+=1;}
		for(int i=0;i<n;i++)
    	{
    		if(f[i]>0) cout<<s[i];
    		else cout<<0;
		}
 } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// typedef long long ll;
#define int long long
#define oku7 1000000007
#define MAXN (int)1e+5 * 2+1
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using P = pair<int, int>;

signed main() {
  int a,b;
  cin >> a >> b;
  cout << 6-a-b << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<iostream>
#include<cmath>
#include<map>
using namespace std;
const int maxn=110;
int a[maxn];
int n;
bool jud(){
	for(int i=0;i<n;i++){
		if(a[i]!=0){
			return false;
		}
	}
	return true;
}
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	int ans=0;
	int flag=0;
	while(!jud()){
		for(int i=0;i<n;i++){
			flag=0;
			while(a[i]>0){
				a[i]--;
				i++;
				flag=1;
			}
			if(flag){
				ans++;
			}
		}
	
	}
	printf("%d",ans);
}

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

int main(){
  int n;
  cin >> n;
  map<int64_t, vector<int64_t>> m;
  vector<int64_t> v(0);
  for(int i= 0; i < n; i++){
    int a;
    cin >> a;
    int64_t s = i + a;
    int64_t d = i - a;
    
    if(m.count(s) == false){
      m[s] = {1, 0};
      v.push_back(s);
    }
    else
      m[s][0]++;
    
    if(m.count(d) == false){
      m[d] = {0, 1};
      v.push_back(d);
    }
    else
      m[d][1]++;
  }
  
  int64_t cnt = 0;
  
  for(int i = 0; i < v.size(); i++){
    int64_t s = m[v[i]][0];
    int64_t d = m[v[i]][1];
    cnt += s*d;
  }
  
  cout << cnt << endl;
  
  return 0;
  
}

Measured memory_bytes: 57332
/**********************************************************************************************
******************************AUTHOR:**********************************************************
****************************ASHISH RANJAN******************************************************
***********************************************************************************************/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<chrono>
#include<vector>
#include<string>
#include<cstring>
using namespace std;
using namespace std::chrono;
/*
auto start = high_resolution_clock::now();
auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
  
    cout << "Time taken by function: "
         << duration.count() << " microseconds" << endl;
*/
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
#define mod 1000000007
#define fr(i,n) for(int i=0;i<n;i++)
#define frs(i,a,b) for(int i = a;i<b;i++)
#define meme(a,b,c) memset(a,b,sizeof(c)); //works only for 0 and -1
int main(){
  fast();
int n,m,k;
cin>>n>>m>>k;
ll arr1[n],arr2[m];
fr(i,n)cin>>arr1[i];
fr(i,m)cin>>arr2[i];
vector<ll> v1(n+1),v2(m+1);
fr(i,n){
   v1[i+1] = v1[i] + arr1[i];
}
fr(i,m){
   v2[i+1] = v2[i] + arr2[i];
}
ll total = 0;
fr(i,n+1){
  ll other = k - v1[i];
  if(other<0)continue;
  ll l = lower_bound(v2.begin(),v2.end(),other)-v2.begin();
  if(l>m||v2[l]>other)l--;
  total = max(total,i+l);
}
cout<<total;
 return 0;
}


Measured memory_bytes: 9488
import java.util.*;
import java.io.*;

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt();
		
		String ans = "";
		
		if(n==0)System.out.println(0);
		while(n!=0){
			if(n%2==0) {
				ans = "0" + ans;
			}else {
				n-=1;
				ans = "1" + ans;
			}
			n /= -2; //ここを-2から2にするだけで２進数も作れる
		}
		System.out.println(ans);
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

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

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

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

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

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

struct Node{
  int key;
  struct Node *r,*l,*p;
};

 struct Node *B,*NIL;

void insert(int k){
   struct Node *y = NIL;
   struct Node *x = B;
   struct Node *z;

   z = (struct Node *)malloc(sizeof(struct Node));
   z->key = k;
   z->l = NIL;
   z->r = NIL;

   while(x!=NIL){
     y = x;
     
     if(z->key < x->key){
       x = x->l;
     }
     else x = x->r;
   }
   
   z->p = y;
   if(y == NIL ){
     B=z;
   }
   else if(z->key < y->key){
       y->l = z;
     }
   else y->r = z;
}

struct Node* find(int k,struct Node *u){
  while( u != NIL && k != u->key ){
    if(k < u->key) u = u->l;
    else u = u->r;
  }
  return u;
}


void inorder(struct Node *u){
  if(u==NIL) return;
  inorder(u->l);
  printf(" %d",u->key);
  inorder(u->r);
}

void preorder(struct Node *u){
  if(u == NIL )return;
  printf(" %d",u->key);
  preorder(u->l);
  preorder(u->r);
}

int main(){
  
  int i,j,x,y;
  char G[8];
  struct Node *s;
  scanf("%d",&x);
  
  for(i=0;i<x;i++){
    scanf("%s",&G);
    
    if(G[0] == 'i'){
      scanf("%d",&y);
      insert(y);
    }
    
    else if(G[0] == 'p'){
      inorder(B);
      printf("\n");
      preorder(B);
      printf("\n");
    }

    else if(G[0]=='f'){
      scanf("%d",&y);
      s = find(y,B);
      if(s != NIL) printf("yes\n");
      else if(s == NIL)printf("no\n");
    }
  }
  return 0;
}

  

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

int main() {
  int a, b;
  cin >> a >> b;
  int s = a + b;
  if (s % 2 == 0) {
    cout << s / 2 << endl;
  }
  else {
    cout << s / 2 + 1 << endl;
  }
}

Measured memory_bytes: 256
import java.lang.reflect.Array;
import java.net.Inet4Address;
import java.util.Arrays;
import java.util.OptionalInt;
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;
import java.util.stream.Collectors;
import java.util.HashSet;
import java.util.HashMap;

public class Main {

    static long gcd(long p, long q) { if(q == 0) return p; return gcd(q, p % q);}
    static Scanner sc = new Scanner(System.in);
    /////////

    static int ret = 0;
    static String str;

    static boolean check(int mid) {
        HashMap<String, Integer> hash = new HashMap<>();

        for(int i = 0; i < str.length(); i += 1) {
            if(i + mid > str.length()) break;

            String subString = str.substring(i, i + mid);

            if(!hash.containsKey(subString)) {
                hash.put(subString, i);
            } else if(hash.get(subString) + mid <= i) {
                return true;
            }
        }


        return false;
    }

    static void parametric_search(int l, int r) {
        if(r < l) return;

        int mid = l + (r - l) / 2;
        if(check(mid)) {
            ret = Math.max(ret, mid);
            parametric_search(mid + 1, r);
        } else {
            parametric_search(l, mid - 1);
        }
    }


    public static void main(String[] args) {
        int N = sc.nextInt(); str = sc.next();

        parametric_search(1, N);

        System.out.println(ret);
    }
}
//[B@25618e91
//[B@326de728
//

Measured memory_bytes: 66012
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#define BIG 10e9
#define SIZE 1000
using namespace std;

void show(int *Array, int ArrayLength) {
	for (int i = 0; i < ArrayLength; i++) {
		if (i != ArrayLength - 1) {
			printf("%d ", Array[i]);
		}
		else {
			printf("%d\n", Array[i]);
		}
	}
}


int selectionSort(int *A, int N) {
	int minj;
	int tmp;
	int c = 0;
	for (int i = 0; i < N - 1; i++) {
		minj = i;
		for (int j = i; j < N; j++) {
			if (A[j] < A[minj])  minj = j;
		}
		tmp = A[i];
		A[i] = A[minj];
		A[minj] = tmp;
		if (i != minj) c++;
	}
	return c;
}

int main() {
	int N;
	int A[SIZE];
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}

	int c = selectionSort(A, N);
	for (int i = 0; i<N; i++) {
		if (i > 0) printf(" ");
		printf("%d", A[i]);
	}
	printf("\n%d\n", c);
	return 0;
}

Measured memory_bytes: 3180
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
#pragma GCC target("popcnt")
#include <bits/stdc++.h>
#define maxn 2010
#define maxv 4000010
#define ll long long
#define ull unsigned long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define pii pair<int, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define IL inline
#define ss system
using namespace std;

int n, k;
ll f[maxn][maxn], fac[maxv], ifac[maxv];
const ll p = 1e9 + 7;
template <class T> void read (T &x) {
  char ch = x = 0;
  bool fl = false;
  while (!isdigit(ch))
    fl |= ch == '-', ch = getchar();
  while (isdigit(ch))
    x = x * 10 + ch - '0', ch = getchar();
  x = fl ? -x : x;
}
ll pw(ll a, ll b) {
  ll ret = 1;
  while (b) {
    if (b & 1)
      ret = ret * a % p;
    a = a * a % p, b >>= 1;
  }
  return ret;
}
ll C(int a, int b) {
  return a < b || b < 0 ? 0 : fac[a] * ifac[b] % p * ifac[a - b] % p;
}
void init() {
  fac[0] = 1;
  for (int i = 1; i < maxv; i++) {
    fac[i] = fac[i - 1] * i % p;
  }
  ifac[maxv - 1] = pw(fac[maxv - 1], p - 2);
  for (int i = maxv - 2; ~i; i--) {
    ifac[i] = ifac[i + 1] * (i + 1) % p;
  }
}
int main() {
  read(n), read(k), init(), f[0][0] = 1;
  for (int i = 0; i <= n; i++) {
    for (int j = !i; j <= i; j++) {
      if (i)
        f[i][j] = f[i - 1][j];
      f[i][j] = (f[i][j] + f[i][j - 1] * (n - j + 1) % p * C(n - i + (n - j + 1) * (k - 1) - 1, k - 2)) % p;
    }
  }
  printf("%d\n", f[n][n * (k > 1)]);
  return 0;
}

Measured memory_bytes: 94208
import sys
H = []
W = []

for l in sys.stdin:
    Ha, Wa = map(int, l.split())
    if Ha == 0 and Wa == 0:
        break
    H.append(Ha)
    W.append(Wa)

for i, numH in enumerate(H):
    for num in range(numH):
        print("#" * W[i])
    print()


Measured memory_bytes: 5628
#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(), v.end()

using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const double PI = 2 * acos(0);

int main() {
	int H, W, K, x1, x2, y1, y2;
	cin >> H >> W >> K;
	string arr[H + 1];
	cin >> x1 >> y1 >> x2 >> y2;
	x1--, x2--, y1--, y2--;	
	for (int i = 0; i < H; i++) {
		cin >> arr[i];
	}
	int dist[H + 1][W + 1];
	for (int i = 0; i < H; i++)
		for (int j = 0; j < W; j++) dist[i][j] = 1e7;
	dist[x1][y1] = 0;
	queue<pair<int, int> > q;
	q.push(mp(x1, y1));
	while (!q.empty()) {
		int x = q.front().fi;
		int y = q.front().se;
		q.pop();
		//atas
		for (int i = x - 1; i >= max(0, x - K); i--) {
			if (arr[i][y] == '@' || dist[i][y] < dist[x][y] + 1) break;
			if (dist[i][y] > dist[x][y] + 1) {
				q.push(mp(i, y));
				dist[i][y] = dist[x][y] + 1;
			}
		}
		//kanan
		for (int i = y + 1; i <= min(W - 1, y + K); i++) {
			if (arr[x][i] == '@' || dist[x][i] < dist[x][y] + 1) break;
			if (dist[x][i] > dist[x][y] + 1) {
				q.push(mp(x, i));
				dist[x][i] = dist[x][y] + 1;
			}
		}
		//bawah
		for (int i = x + 1; i <= min(H - 1, x + K); i++) {
			if (arr[i][y] == '@' || dist[i][y] < dist[x][y] + 1) break;
			if (dist[i][y] > dist[x][y] + 1) {
				q.push(mp(i, y));
				dist[i][y] = dist[x][y] + 1;
			}
		}
		//kiri
		for (int i = y - 1; i >= max(0, y - K); i--) {
			if (arr[x][i] == '@' || dist[x][i] < dist[x][y] + 1) break;
			if (dist[x][i] > dist[x][y] + 1) {
				q.push(mp(x, i));
				dist[x][i] = dist[x][y] + 1;
			}
		}
	}
	if (dist[x2][y2] == 1e7) printf("-1\n");
	else printf("%d\n", dist[x2][y2]);
}

Measured memory_bytes: 9544
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int main(){
    int num[4] = {};
    rep(i,3){
        int a,b;
        cin >> a >> b;
        a--,b--;
        num[a]++;
        num[b]++;
    }
    sort(num,num+4);
    if(num[0] == 1 and num[1] == 1 and num[2] == 2 and num[3] == 2){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (unsigned int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD =  1000000007 ;
const int INF = 2000000000;


    ll A,B,C,D,E,N,X[10];
    ll ans=0;
    string S;
    bool F=false;
int main(){
    cin>>A>>B>>C;
    for(int i=A;i<=B;i++){if(i%C==0)ans++;}
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3628
/**
 *    author:  math2do
 *    created: 21.11.2019 16:19:13
**/

#include <bits/stdc++.h>

using namespace std;
using lli = long long int;

vector <vector <lli>> dp(100, vector <lli>(100001, -1));

lli solve(int idx, int n, int w, vector <vector <int>> &mat) {
  if (idx == n) return 0;
  if (dp[idx][w] != -1) return dp[idx][w];

  lli ans = 0;
  if (w - mat[idx][0] >= 0) {
    ans = max(ans, mat[idx][1] + solve(idx + 1, n, w - mat[idx][0], mat));
  }
  ans = max(ans, solve(idx + 1, n, w, mat));
  return dp[idx][w] = ans;
} 

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  #ifdef LOCAL
    freopen("knapsack_1.in", "rt", stdin);
  #endif
  int n, w;
  cin >> n >> w;
  vector <vector <int>> mat(n, vector <int>(2));
  for (int i = 0; i < n; i++) {
    cin >> mat[i][0] >> mat[i][1];
  }


  //for (int i = 0; i < 10; i++) {
  //  for (int j = 0; j < 10; j++) {
  //    cout << dp[i][j] << " ";
  //  }
  //  cout << endl;
  //} 

  lli ans = solve(0, n, w, mat);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 79360
#include<bits/stdc++.h>
using namespace std;
#define int long long

const int N = 1e5+10;
int a[N];

signed main(){

  int n,A,B; cin >> n >> A >> B;
  for(int i = 0; i < n; i++) cin >> a[i];

  int ans = 0;
  for(int i = 0; i < n-1; i++){
    if((a[i+1]-a[i]) * A <= B) ans += (a[i+1]-a[i]) * A;
    else ans += B;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(){
	string s; cin>>s;
	int a = 1e9;
	for(char c='a'; c<='z'; c++){
		int lo = -1;
		int mr = 0;
		for(int x=0; x<s.length(); x++){
			mr = max(mr, (int)x-lo-1);
			if(s[x]==c)
				lo = x;

		}
//		cout << lo << endl;
		mr = max(mr, (int)s.length()-lo-1);
		a = min(a, mr);
	}
	cout << a << endl;
	return 0;
}

Measured memory_bytes: 256
s = input()

if s == 'SUN':
  print(7)
elif s == 'MON':
  print(6)
elif s == 'TUE':
  print(5)
elif s == 'WED':
  print(4)
elif s == 'THU':
  print(3)
elif s == 'FRI':
  print(2)
elif s == 'SAT':
  print(1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define INV 250000002
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
string str;
void add(ll &a,ll b) {a+=b;}
ll p2[MAXN],p5[MAXN];
int main()
{
    p2[0]=p5[0]=1;
    for(int i=1;i<=100000;i++) p2[i]=2LL*p2[i-1];
    for(int i=1;i<=100000;i++) p5[i]=5LL*p5[i-1];
    cin>>str;
    int n=str.size();
    ll ans=0;
    for(int i=0;i<n;i++)
    {
        if(i!=n-1) add(ans,1LL*p2[n-2]*(str[i]-'0')*(p5[n-i-1]-1)/4);
        add(ans,1LL*(str[i]-'0')*p2[i]*p2[n-i-1]*p5[n-i-1]);
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 5276
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i, n) for (int i = 0, i##_cond = (n); i < i##_cond; ++i)
#define FOR(i, a, b) for (int i = (a), i##_cond = (b); i < i##_cond; ++i)
#define ROF(i, a, b)                                                           \
  for (int i = (a)-1, i##_cond = (b); i >= i##_cond; --i) // ROF(i,n,0)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend() // sortで降順
#define SUM(a) accumulate(all(a), int(0))
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
constexpr ll inf = 1ll << 61;
constexpr ll mod = 1e9 + 7;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> T add(const T &a, const T &b) { return (a + b) % mod; }

signed main() {
  vi a(5);
  rep(i, 5) { cin >> a[i]; }
  rep(i, 5) {
    if (a[i] == 0) {
      cout << i + 1 << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3588
#include <iostream>
#include <string>

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

using namespace std;
string r, a;

void solve() {
    int hit = 0;
    int blow = 0;
    rep(i, 4) {
        if (r[i] == a[i]) hit++;
    }
    rep(i, 4) rep(j, 4) {
        if (i != j && r[i] == a[j]) blow++;
    }
    cout << hit << " " << blow << endl;
}

int main() {
    while (cin >> r >> a) {
        if (r == "0" && a == "0") break;
        solve();
    }
}

Measured memory_bytes: 3156
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <time.h>

#include <string>

const int MAX_N = 100050;

long long N, C;
long long x[MAX_N], v[MAX_N];

long long bpR[MAX_N], bpL[MAX_N];
long long bvR[MAX_N], bvL[MAX_N];

int main(int argc, char **argv) {
    std::cin >> N >> C;
    for (int i = 1; i <= N; i++) {
        std::cin >> x[i] >> v[i];
    }
    
    long long tmp = 0;
    long long tmp_best = 0;
    long long tmp_best_pos = 0;

    for (int i = 1; i <= N; i++) {
        tmp += v[i];
        if (tmp_best < tmp - x[i]) {
            tmp_best = tmp - x[i];
            tmp_best_pos = i;
        }
        bpR[i] = tmp_best_pos;
        bvR[i] = tmp_best;
    }

    tmp = 0;
    tmp_best = 0;
    tmp_best_pos = 0;
    for (int i = N; 1 <= i; i--) {
        tmp += v[i];
        if (tmp_best < tmp - (C - x[i])) {
            tmp_best = tmp - (C - x[i]);
            tmp_best_pos = i;
        }
        bpL[i] = tmp_best_pos;
        bvL[i] = tmp_best;
    }

    x[0] = 0;
    bpR[0] = 0; bpL[0] = 0;
    bvR[0] = 0; bvL[0] = 0;

    long long ret = 0;
    for (int i = 1; i <= N; i++) {
        ret = std::max(ret, bvR[i]);
        ret = std::max(ret, bvL[i]);
        if (i != N) {
            ret = std::max(ret, bvR[i] - x[bpR[i]] + bvL[bpR[i] + 1]);
        }
        if (i != 1) {
            ret = std::max(ret, bvL[i] - (C - x[bpL[i]]) + bvR[bpL[i] - 1]);
        }
    }

    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
    int N;
    cin >> N;
    long long A[N];
    for(int i =0; i < N; i++){
        cin >> A[i];
    }
    long long  g = A[0];
    for(int i = 1; i < N; i++){
        g = __gcd(A[i],g);
    }
    cout << g << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define vd vector<ld>
#define vvd vector<vector<ld>>
#define ALL(a) begin(a), end(a)
#define RALL(a) rbegin(a), rend(a)
#define SORT(a) stable_sort(ALL(a))
#define RSORT(a) stable_sort(RALL(a))
#define REV(a) reverse(ALL(a))
#define lambda(i) [](auto& i)
#define compare(i, j) [](auto& i, auto& j)
#define min_of(a) *min_element(ALL(a))
#define max_of(a) *max_element(ALL(a))
#define sum(a) accumulate(ALL(a), 0)
#define pb push_back
#define mp make_pair
#define SZ(a) ll((a).size())
#define REP(i, n) for (decltype(n) i = 0; i < (n); i++)
#define RREP(i, n) for (auto i = n - 1; i != static_cast<decltype(i)>(-1); i--)
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define RFOR(i, a, b) for (auto i = b - 1; i != a; i--)
#define EACH(i, a) for (auto&& i: (a))
using namespace std;

const ll INF = 1e18;
const ll mod = 1e9 + 7;

vi cum(vi V) {
  vi U(SZ(V));
  partial_sum(ALL(V), begin(U));
  return U;
}

void solve() {
  ll n;
  ll ans = 0;

  cin >> n;
  vi h(n);
  REP(i, n) {
    cin >> h[i];
  }
  ll ci = 0;
  REP(i, n - 1) {
    if (h[i] < h[i + 1]) {
      ans = max(ans, i - ci);
      ci = i + 1;
    }
  }
  ans = max(ans, n - 1 - ci);

  cout << ans << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << fixed << setprecision(15);
  solve();
}


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

ll gcd(ll a, ll b){
  return (b != 0) ? gcd(b, a%b) : a;
}

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n+2, 0);
  rep(i, n) cin >> a[i+1];
  ll pay = 0;
  rep(i, n+1) pay += abs(a[i+1] - a[i]);
  for(int i = 1; i <= n; ++i){
    cout << pay - abs(a[i]-a[i-1]) - abs(a[i+1]-a[i]) + abs(a[i+1]-a[i-1])  << "\n"; 
  }
  
}  

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
int D, T, S;
		cin >> D >> T >> S;
		if ((D+S-1)/S<=T) {
			cey;
		}
		else {
			cen;
		}
    return 0;
}



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

static const int N = 100;

int main() {
	int M[N][N];
	int n, u, k, v;

	cin >> n;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++)M[i][j] = 0;
	}

	for (int i = 0; i < n; i++) {
		cin >> u >> k;

		u--;
		for (int j = 0; j < k; j++) {
			cin >> v;
			v--;
			M[u][v] = 1;
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (j)cout << " ";
			cout << M[i][j];
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3148
#include <cstdio>
#include <cstdlib>
using namespace std;

struct POINT
{
	int x;
	int y;
};

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

POINT sp[10];
int n;

bool Search(int i, int x, int y)
{	
	bool f = false;
	
//	printf("%d %d\n", x, y);
	
	if (i == n){
		return true;
	}
	
	for (int j = 0; j < 12; j++){		
		if (abs(x + dx[j] - sp[i].x) <= 1 && abs(y + dy[j] - sp[i].y) <= 1
		&& (x + dx[j] >= 0 && x + dx[j] <= 9 && y + dy[j] >= 0 && y + dy[j] <= 9)){
			if (Search(i + 1, x + dx[j], y + dy[j])){
				f = true;
				break;
			}
		}
	}
	
	return f;
}

int main()
{
	POINT def;
	
	while (scanf("%d %d", &def.x, &def.y), def.x + def.y){
		scanf("%d", &n);
		
		for (int i = 0; i < n; i++){
			scanf("%d %d", &sp[i].x, &sp[i].y);
		}
		
		printf(Search(0, def.x, def.y) ? "OK\n" : "NA\n");
	}
	
	return 0;
}

Measured memory_bytes: 1012
N=int(input())
testimony={}
for i in range(N):
    Ai=int(input())
    tmp=[]
    for j in range(Ai):
        xy=list(map(int,input().split()))
        tmp.append(xy)
    testimony[i+1]=tmp
#print(testimony)

ans=0
#ビット全探索
for bit in range(2**N):
    test=[]
    for i in range(N):
        if (bit>>i)&1:
            test.append(1)
        else:
            test.append(0)
    flag=True
    for i in range(N):
        if test[i]==1:
            for j in testimony[i+1]:
                if j[1]!=test[j[0]-1]:
                    flag=False
                else:
                    pass
        else:
            pass
    if flag==True:
        ans=max(ans,sum(test))
    else:
        pass

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
void ans(int i){
    if(i)out("Second");
    else out("First");
}
int main(){
    ll n;cin>>n;
    vi v(n);
    rep(i,n)cin>>v[i];
    if(n==1)dame("Second");
    ll sum=0;
    rep(i,n)sum+=v[i]-1;
    if(sum&1)dame("First");
    while(true){
        int cnt=0;
        rep(i,n)if(v[i]%2)cnt++;
        if(cnt>1){
            ans(1-sum%2);
            return 0;
        }
        rep(i,n){
            if(v[i]&1){
                if(v[i]==1){
                    ans(1-sum%2);
                    return 0;
                }
                v[i]--;
            }
        }
        ll g=v[0];
        rep(i,n)g=gcd(g,v[i]);
        rep(i,n)v[i]/=g;
        ll s=0;
        rep(i,n)s+=v[i]-1;
        if(s%2){
            ans(1-sum%2);
            return 0;
        }
        sum--;
    }
}

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

long a[51],b[51];

long dfs(int n,long k){
    if(n==0&&k>=1){
        return 1;
    }
    else if(k<=1){
        return 0;
    }
    if(k>a[n]/2){
        return (long)1+b[n-1]+dfs(n-1,k-a[n]/2-1);
    }
    else if(k==a[n]/2){
        return b[n-1];
    }
    return dfs(n-1,k-1);
}

int main(){
    int n;
    long k,ans=0;
    scanf("%d %ld",&n,&k);
    a[0]=(long)1;
    b[0]=(long)1;
    for(int i=1;i<=50;i++){
        a[i]=a[i-1]*(long)2+(long)3;
        b[i]=b[i-1]*(long)2+(long)1;
    }
    printf("%ld\n",dfs(n,k));
}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define fin(name) freopen(name, "r", stdin)
#define fout(name) freopen(name, "w", stdout)
#define I(x, a) for(auto x : a)
#define F(i, l, r) for(auto i = l; i != r; ++i)
#define DF(i, l, r) for(auto i = l; i != r; --i)
#define clean(a) memset((a),0,sizeof (a))
#define sync ios_base::sync_with_stdio(0);cin.tie(0)
#define all(x) x.begin(),x.end()
#define ret return
#define cont continue
#define brk break
#define ins insert

typedef long long ll;
typedef unsigned long long ull;
typedef long double dbl;
typedef pair <int, int> pii;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int) 1e9 + 7;
const dbl eps = (dbl) 1e-8;
const int maxn = (int) 1e5 + 5;
const dbl pi = acos(-1);

int t[4 * maxn];

int sum(int v, int l, int r, int tl, int tr)
{
	if (l > r || tl > tr)
		ret 0;
	if (l == tl && r == tr)
		ret t[v];
	int m = (l + r) / 2;
	ret sum(2 * v, l, m, tl, min(tr, m)) + sum(2 * v + 1, m + 1, r, max(tl, m + 1), tr);
}

void upd(int v, int l, int r, int pos)
{
	if (pos < l || pos > r)
		ret;
	if (l == r)
	{
		t[v] = 1;
		ret;
	}
	int m = (l + r) / 2;
	upd(2 * v, l, m, pos);
	upd(2 * v + 1, m + 1, r, pos);
	t[v] = t[2 * v] + t[2 * v + 1];
}

ll A[maxn], B[maxn], C[maxn], n;
int pos_in_z[maxn], pos_in_z_r[maxn];
dbl z[maxn], k[maxn], p[maxn];
pair <dbl, int> a[maxn], b[maxn];

ll cnt(dbl x)
{
	ll ans = 0;	
	F(i, 0, n)
	{
		z[i] = p[i] + x * k[i];
		a[i] = mp(z[i], i);
	}
	sort(a, a + n);
	int r = -1;
	F(i, 0, n)
	{
		pos_in_z[a[i].Y] = i;
		if (i == n - 1 || a[i + 1].X > a[i].X)
			r = i;
		pos_in_z_r[a[i].Y] = r;
	}
	memset(t, 0, sizeof(int)*(4 * n + 5));
	F(i, 0, n)
	{
		dbl tz = z[b[i].Y];
		ll plus = sum(1, 0, n - 1, 0, pos_in_z_r[b[i].Y]);
//		cout << i << " " << plus << " " << tz << endl;
		ans += plus;
		upd(1, 0, n - 1, pos_in_z[b[i].Y]);
	}
	
	ret ans;
}

dbl solve()
{
	F(i, 0, n)
	{
		b[i] = mp(k[i], i);
	}
	sort(b, b + n);

	dbl l = -1e14, r = 1e14;
	ll n2 = (ll)n * (n - 1) / 2;
	if (n2 % 2 == 0)
		n2 = n2 / 2;
	else
		n2 = n2 / 2 + 1;
//	cout << cnt(-1) << endl;
//	exit(0);
	F(iter, 0, 90)
	{
		dbl m = (l + r) / (dbl)2;
		if (cnt(m) < n2)
			l = m;
		else
			r = m;
	}
	ret r;
}

int main()
{
//    fin("t.in");
    sync;
    cin >> n;
    F(i, 0, n)
    {
    	cin >> A[i] >> B[i] >> C[i];
//    	A[i] = rand() + 1;
//    	B[i] = rand() + 1;
//    	C[i] = rand();
    	C[i] = -C[i];
    }
 	F(i, 0, n)
 	{
 		k[i] = -(dbl)A[i] / B[i];
 		p[i] = -(dbl)C[i] / B[i];
 	}
 	cout << fixed << setprecision(20);
 	cout << solve() << " ";
 	F(i, 0, n)
 	{
 		k[i] = -(dbl)B[i] / A[i];
 		p[i] = -(dbl)C[i] / A[i];
 	}
 	cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 14208
using System;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split(' ');
        int[] A = new int[110];
        var Bob = 0;
        var Alice = 0;
        
        for (int i=0; i<N; ++i)
        {
            A[i] = int.Parse(a[i]);
        }

        for (int j=0; j<N; ++j)
        {
            for (int i=0; i<N; ++i)
            {
                if(A[i] < A[i+1])
                {
                    var B = A[i];
                    A[i] = A[i+1];
                    A[i+1] = B;
                }
            }
        }

        for (int i=0; i<N; ++i)
        {
            if((i+1)%2 == 0)
            {
                Bob += A[i];
            } else {
                Alice += A[i];
            }
        }

        Console.WriteLine(Alice-Bob);
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;
const ll MOD=1e9+7;
const int MAX_N=1e5+10;
ll extgcd(ll a, ll b, ll& x, ll&y){
    ll d=a;
    if(b!=0){
        d=extgcd(b, a%b, y, x);
        y-=(a/b)*x;
    }
    else {
        x=1; y=0;
    }
    return d;
}

ll mod_inverse(ll a, ll m){
    ll x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}
ll fact[MAX_N];//0<=n<pについてn! modpのテーブルO(p)

//n!=a p＾eとした時のa modpを求める。O(log_p n)
ll mod_fact(ll n, ll p, ll& e){
    e=0;
    if(n==0) return 1;
    
    //pの倍数の部分を計算
    ll res=mod_fact(n/p,p,e);
    e+=n/p;
    
    //(p-1)!≡-1なので(p-1)!^(n/p)はn/pの偶奇だけで計算できる
    if(n/p%2!=0) return res*(p-fact[n%p])%p;
    return res*fact[n%p]%p;
}

//nCk modpを求める。O(log_p n)
ll mod_comb(ll n, ll k, ll p){
    if(n<0||k<0||n<k) return 0;
    ll e1, e2, e3;
    ll a1=mod_fact(n,p,e1), a2=mod_fact(k,p,e2), a3=mod_fact(n-k,p,e3);
    if(e1>e2+e3) return 0;
    return a1*mod_inverse(a2*a3%p,p)%p;
}
bool c[100001];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    int a[n+1];
    int d;
    rep(i,0,n+1){
        cin>>a[i];
        if(c[a[i]]) d=i;
        c[a[i]]=1;
    }
    int s=0, t=0, u=0;
    int i=0;
    while(a[i]!=a[d]){
        s++;
        i++;
    }
    i++;
    while(a[i]!=a[d]){
        t++;
        i++;
    }
    i++;
    u=n-i+1;
    fact[1]=1;
    rep(i,2,MAX_N){
        fact[i]=fact[i-1]*i;
        fact[i]%=MOD;
    }
    rep(j,1,n+2){
        if(j==1) cout <<n<<"\n";
        else if(j==n+1) cout <<1<<"\n";
        else{
            cout << ((s+t+u>=j?mod_comb(s+t+u,j, MOD):0)+(s+t+u>=j-2?mod_comb(s+t+u, j-2, MOD):0)+(s+u>=j-1?mod_comb(s+u, j-1, MOD):0)+((s+t+u>=j-1?mod_comb(s+t+u, j-1, MOD):0)-(s+u>=j-1?mod_comb(s+u, j-1, MOD):0)+MOD)*2)%MOD<<"\n";
        }
    }
}

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

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

  int n = sqrt(N);
  long long W;
  for (int i = n; i >= 1; i--)
  {
    if (N % i == 0)
    {
      W = i;
      break;
    }
  }

  long long H = N / W;
  cout << W + H - 2 << endl;
}


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

const int MAX = 1e5;

int it;
int lv[MAX], rv[MAX];
int id[MAX];

void euler_tour(int v, const graph& G) {
	id[it] = v;
	lv[v] = it++;
	for (auto to : G[v]) {
		euler_tour(to, G);
	}
	rv[v] = it;
}

unsigned xor128() {
	static unsigned x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	unsigned t = x ^ (x << 11);
	x = y; y = z; z = w;
	return w = w ^ (w >> 19) ^ (t ^ (t >> 8));
}

struct node {
	int val, sum;
	node *lch, *rch;
	int size;
	node(int v, node* l = nullptr, node* r = nullptr) : val(v), sum(v), lch(l), rch(r), size(1) {}
};

int count(node *t) { return t ? t->size : 0; }
int getsum(node *t) { return t ? t->sum : 0; }

node *update(node *t) {
	t->size = count(t->lch) + count(t->rch) + 1;
	t->sum = getsum(t->lch) + t->val + getsum(t->rch);
	return t;
}

node *merge(node *l, node *r) {
	if (!l) return r;
	if (!r) return l;
	if ((int)xor128() % (l->size + r->size) < l->size) {
		l->rch = merge(l->rch, r);
		return update(l);
	}
	r->lch = merge(l, r->lch);
	return update(r);
}

pair<node*, node*> split(node *t, int k) {
	if (!t) return make_pair(nullptr, nullptr);
	if (k <= count(t->lch)) {
		pair<node*, node*> s = split(t->lch, k);
		t->lch = s.second;
		return make_pair(s.first, update(t));
	}
	pair<node*, node*> s = split(t->rch, k - count(t->lch) - 1);
	t->rch = s.first;
	return make_pair(update(t), s.second);
}

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q;
	cin >> n >> q;
	graph G(n);
	for (int i = 1; i < n; i++) {
		int p;
		cin >> p; p--;
		G[p].push_back(i);
	}
	euler_tour(0, G);
	vector<char> c(n);
	for (int i = 0; i < n; i++) {
		cin >> c[i];
	}
	node *t = nullptr, *rt = nullptr;
	for (int i = 0; i < n; i++) {
		t = merge(t, new node(c[id[i]] == 'G'));
		rt = merge(rt, new node(c[id[i]] == 'W'));
	}
	while (q--) {
		int v;
		cin >> v; v--;

		auto s1 = split(t, lv[v]);
		auto s2 = split(s1.second, rv[v] - lv[v]);
		auto rs1 = split(rt, lv[v]);
		auto rs2 = split(rs1.second, rv[v] - lv[v]);

		t = merge(s1.first, merge(rs2.first, s2.second));
		rt = merge(rs1.first, merge(s2.first, rs2.second));

		puts(getsum(t) > getsum(rt) ? "broccoli" : "cauliflower");
	}
	return 0;
}



Measured memory_bytes: 23672
#insertion sort

n = int(input())
A = list(map(int,input().split()))

print(*A)

for i in range(1,n):
    j = i
    while(j > 0):
        if A[j-1] > A[j]:
            A[j-1],A[j] = A[j],A[j-1] #SWAP
            j -= 1
        else:
            break
    
    print(*A)


Measured memory_bytes: 5980
class dice:
    def __init__(self, f):
        assert(len(f) == 6)
        self.face = f
        self.N = [1, 5, 2, 3, 0, 4]
        self.S = [4, 0, 2, 3, 5, 1]
        self.E = [3, 1, 0, 5, 4, 2]
        self.W = [2, 1, 5, 0, 4, 3]
        self.R = [0, 2, 4, 1, 3, 5]

    def rotate(self, dir):
        rot = self.__getattribute__(dir)
        old = self.face
        new = [-1 for _ in range(6)]
        for i in range(6):
            new[i] = old[rot[i]]
        self.face = new

    def __eq__(self, E):
        D = self
        for _ in range(4):
            # print(f'a {D.face}')
            if D.face[0] == E.face[0]:
                for _ in range(4):
                    # print(f'b {D.face}')
                    if D.face == E.face:
                        return True
                    else:
                        D.rotate('R')
            D.rotate('N')
        for _ in range(4):
            # print(f'c {D.face}')
            if D.face[0] == E.face[0]:
                for _ in range(4):
                    # print(f'd {D.face}')
                    if D.face == E.face:
                        return True
                    else:
                        D.rotate('R')
            D.rotate('E')
        return False

A = dice(list(map(int, input().split())))
B = dice(list(map(int, input().split())))
print('Yes' if A == B else 'No')



Measured memory_bytes: 5612
n, m, q = map(int, input().split())

candidate = []


def gen(cur):
    if len(cur) == n:
        candidate.append(cur)
    else:
        t = cur[-1]
        for tv in range(t, m + 1):
            nex = cur[:]
            nex.append(tv)
            gen(nex)


for i in range(1, m + 1):
    arr = [i]
    gen(arr)

ask = []
for _ in range(q):
    ask.append(list(map(int, input().split())))

ans = 0
for cv in candidate:
    tmp = 0
    for av in ask:
        if cv[av[1] - 1] - cv[av[0] - 1] == av[2]:
            tmp += av[3]
    ans = max(ans, tmp)
print(ans)

Measured memory_bytes: 28620