akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

	public static final int BIG_NUM = 2000000000;
	public static final int MOD = 1000000007;
	public static final long HUGE_NUM = 99999999999999999L;
	public static final double EPS = 0.000000001;

	@SuppressWarnings("unchecked")
	public static void main(String[] args) {

		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Scanner scanner = new Scanner(System.in);

		int SIZE = 505;
		int min_dist[] = new int[SIZE];
		ArrayList<Edge> list[] = new ArrayList[SIZE];

		for(int i = 0; i < SIZE; i++){

			list[i] = new ArrayList<Edge>();
		}

		int base = 0;

		while(true){

			int V = scanner.nextInt();
			int E = scanner.nextInt();

			if(V == 0 && E == 0)break;

			for(int i = 0; i < V; i++){

				min_dist[i] = BIG_NUM;
				list[i].clear();
			}

			for(int loop = 0; loop < E; loop++){

				int from = scanner.nextInt();
				int to = scanner.nextInt();
				from--;
				to--;

				list[from].add(new Edge(to,1));
				list[to].add(new Edge(from,1));
			}

			PriorityQueue<Info> Q = new PriorityQueue<Info>();
			min_dist[base] = 0;
			Q.add(new Info(base,0));

			while(!Q.isEmpty()){

				if(Q.peek().sum_dist > min_dist[Q.peek().node_id]){

					Q.poll();

				}else{

					for(int i = 0; i < list[Q.peek().node_id].size(); i++){

						int next_node = list[Q.peek().node_id].get(i).to;
						int next_dist = Q.peek().sum_dist+1;

						if(min_dist[next_node] > next_dist){

							min_dist[next_node] = next_dist;
							Q.add(new Info(next_node,next_dist));
						}
					}
					Q.poll();
				}
			}

			int ans = 0;

			for(int i = 1; i < V; i++){
				if(min_dist[i] <= 2)ans++;
			}

			System.out.println(ans);
		}
	}
}

class Info implements Comparable<Info>{
	public int node_id;
	public int sum_dist;

	Info(int arg_node_id,int arg_sum_dist){
		this.node_id = arg_node_id;
		this.sum_dist = arg_sum_dist;
	}

	public int compareTo(Info arg){
		if(this.sum_dist < arg.sum_dist)return -1;
		if(this.sum_dist > arg.sum_dist)return 1;
		return 0;
	}
}


class Edge{

	public int to;
	public int dist;

	Edge(int arg_to,int arg_dist){
		to = arg_to;
		dist = arg_dist;
	}
}

class UTIL{

	//最大公約数
	public static long gcd(long x,long y){

		x = Math.abs(x);
		y = Math.abs(y);

		if(x < y){

			long tmp = y;
			y = x;
			x = tmp;
		}

		if(y == 0){

			return x;
		}else{

			return gcd(y,x%y);
		}
	}

	//最小公倍数
	public static long lcm(long x,long y){

		return (x*y)/gcd(x,y);
	}

	//String→intへ変換
    public static int getNUM(String tmp_str){

        return Integer.parseInt(tmp_str);
    }

    //文字が半角数字か判定する関数
    public static boolean isNumber(String tmp_str){

        if(tmp_str == null || tmp_str.length() == 0){

            return false;
        }

        Pattern pattern = Pattern.compile("\\A[0-9]+\\z");
        Matcher matcher = pattern.matcher(tmp_str);
        return matcher.matches();
    }
}


Measured memory_bytes: 54100
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef unsigned long long ull;
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}

inline void solve(void){
  int N;
  in(N);
  vector<int>A(N);
  rep(i,N){
    int t;
    in(t);
    A[t-1]=i+1;
  }
  rep(i,N)cout<<A[i]<<" \n"[i==N-1];
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 1280
#include<stdio.h>
#include<string.h>
int main(){
  int n;
  char s[200];
  char s1[100];
  char s2[100];
  int a;
  
  scanf("%d",&n);
  a=n/2;
  
  if(n%2==1){
    printf("No");
  }
  
  else{
    for(int i=0;i<n;i++){
      scanf("%s",&s[i]);
    }
    
    for(int i=0;i<a;i++){
      if(s[i]!=s[i+a]){
        printf("No");
        break;
      	return 0;
      }
      else  if(i==(a-1)){
    	printf("Yes");
      	break;
      }
      else {}
    }
  }
  return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-

if __name__ == '__main__':

	l = input()
	S1, S2 = [], []
	
	sum = 0
	n = len(l)
	for i in range(n):
		if l[i] == "\\":
			S1.append(i)
		elif l[i] == "/" and S1:
			j = S1.pop()
			a = i - j
			sum += a
	
			while S2 and S2[-1][0] > j:
				a += S2.pop()[1]
			S2.append([j, a])
	
	print(sum)
	print(len(S2), *(a for j, a in S2))

Measured memory_bytes: 8300
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <numeric>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)

int main() {
    int n;
    cin >> n;
    
    int cnt = 0;
    for (int i = 1; i <= n; i+=2) {
        int yakusuu = 0;
        for (int j = 1; j <= i; j++) {
            if (i%j == 0) yakusuu++;
        }
        if (yakusuu == 8) cnt++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let h: usize = read(&mut stdin_lock, &mut buf, b' ');
    let w: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut g = vec![vec!['#'; w + 2]; h + 2];
    for i in 1..h + 1 {
        let line: String = read(&mut stdin_lock, &mut buf, b'\n');
        for (jz, c) in line.chars().enumerate() {
            g[i][jz + 1] = c;
        }
    }

    let mut tbl = vec![vec![0i32; w + 2]; h + 2];
    for i in 1..h + 1 {
        for j in 1..w + 1 {
            if i == 1 && j == 1 {
                tbl[i][j] = 1;
            } else {
                tbl[i][j] = (if g[i - 1][j] == '.' { tbl[i - 1][j] } else { 0 }
                    + if g[i][j - 1] == '.' { tbl[i][j - 1] } else { 0 })
                    % 1_000_000_007;
            }
        }
    }
    println!("{}", tbl[h][w]);
}


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

int main()
{
    int n;
    double count=0;
    cin>>n;

    for(int i=1;i<=n;i++)
    {
        if(i%2 != 0)
            count++;
    }

    double t=count/n;

    cout<<fixed<<setprecision(10)<<t<<endl;

    return 0;
}


Measured memory_bytes: 256
N = input()

x = N[len(N)-1]

hon = [2, 4, 5, 7, 9]
pon = [0, 1, 6, 8]
bon = [3]

if int(x) in hon:
    print("hon")

elif int(x) in pon:
    print("pon")

else:
    print("bon")


Measured memory_bytes: 80180
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    string s;
    cin >> n >> s;

    if (n % 2 == 1) {
        cout << "No";
        return 0;
    }
    int x = n / 2;

    if (s.substr(0, x) == (s.substr(x, x))) {
        cout << "Yes";
    } else {
        cout << "No";
    }

    return 0;
}

Measured memory_bytes: 256
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/* 
 * File:   main.c
 * Author: kundaikwangwari
 *
 * Created on August 5, 2019, 1:10 AM
 */


#include<stdio.h>
#include<string.h>
#include<stdlib.h>

struct node{

  struct node *right;
  struct node *left;
  struct node *p;
  int key;
};

typedef struct node *Node;
Node root;



Node Find(Node x, int key){

  if(x == NULL||key == x->key)return x;
  if(key < x->key)return Find(x->left,key);
 else return Find(x->right,key);
}

void Preorder(Node u){

  if(u != NULL){
    printf(" %d", u->key);
    Preorder(u->left);
    Preorder(u->right);
  }
}

void Inorder(Node x){

  if(x != NULL){
    Inorder(x->left);
    printf(" %d", x->key);
    Inorder(x->right);
  }
}


Node MinTree(Node node){
while(node->left!=NULL)node=node->left;
  return node;
}

Node FindSuccessor(Node s){

  if(s->right != NULL)return MinTree(s->right);
  Node successor = s->p;
  while(successor != NULL && s == successor->right){

    s=successor;
    successor=successor->p;
  }

  return successor;
}

void treeDelete(Node z){

  Node toDelete, toDelete_Child;

  if(z->left == NULL || z->right == NULL)toDelete = z;
  else toDelete = FindSuccessor(z);

  if(toDelete->left != NULL)toDelete_Child =toDelete->left;
  else toDelete_Child = toDelete->right;

  if(toDelete_Child != NULL)toDelete_Child->p =toDelete->p;
  
  if(toDelete->p == NULL)root =toDelete_Child;
  else if(toDelete == toDelete->p->left)toDelete->p->left =toDelete_Child;
  else toDelete->p->right =toDelete_Child;

  if(toDelete != z)z->key=toDelete->key;
}

void InsertNode(int key){

  Node p = NULL, q = root, newNode;

  newNode = malloc(sizeof(struct node));
  newNode->key = key;
  newNode->left = NULL;
  newNode->right = NULL;

  while(q != NULL){
    p = q;

    if(newNode->key < q->key)q =q->left;
    else q = q->right;
  }

  newNode->p = p;

  if(p == NULL)root =newNode;
  else if(newNode->key < p->key)p->left =newNode;
  else p->right =newNode;
}



int main(){

  int opp, val,flag2;//flag2 control the printing process
    char cmd[8];
    char cmd1[] = "insert";
    char cmd2[] = "print";
    char cmd3[] = "find";
    char cmd4[] = "delete";
    
    scanf("%d",&opp);
    
    for(int a = 0; a < opp; a++){
        scanf("%s",cmd);

    if (strcmp(cmd3,cmd)==0){
      scanf("%d", &val);

      Node Query = Find(root, val);
      if ( Query != NULL )
        printf("yes\n");
      else
        printf("no\n");
    }
    if(strcmp(cmd1,cmd)==0){

      scanf("%d", &val);
      InsertNode(val);
    }
    if(strcmp(cmd2,cmd)==0){

      Inorder(root);
      printf("\n");

      Preorder(root);
      printf("\n");

    } 
    if (strcmp(cmd4,cmd)==0){

      scanf("%d", &val);
      treeDelete(Find(root, val));
    }
  }
  return 0;
}


Measured memory_bytes: 20564
#include <bits/stdc++.h>
    using namespace std;
    
    int main() {

        int x;
        cin >> x;

        int maisu,amari,fyyen,fyen;
        
        fyyen = x/500;
        amari = x % 500;

        fyen =amari/5;

        cout << 1000 * fyyen + 5*fyen << endl;

 
    }

Measured memory_bytes: 256
import java.util.*;
import java.io.InputStreamReader;
import java.io.BufferedReader;


public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] abt = br.readLine().split(" ");
        int a = Integer.parseInt(abt[0]);
        int b = Integer.parseInt(abt[1]);
        int t = Integer.parseInt(abt[2]);
        
        
        int ans = t/a*b;
        
        System.out.println(ans);
    }
}





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

#define ll long long
#define INF 99999999
#define INF_LL 1LL << 60
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    int A,B,C;
    cin >> A >> B >> C;
    if( A >= B && A >= C ) A *= 10;
    else if( B >= A && B >= C ) B *= 10;
    else C *= 10;
    cout << A + B + C << endl;

}


Measured memory_bytes: 256
def sack(N,W,vwmlist):
    val_i = [0]*(W+1)
    for i in range(1,N+1):
        v = vwmlist[i-1][0]
        w = vwmlist[i-1][1]
        m = vwmlist[i-1][2]
        #print(v,w,m)
        copy = val_i[:]
        num = [0for i in range(W+1)]
        for j in range(1,W+1):
            if (w <= j and num[j-w] < m):
                val_i[j] = max(copy[j], (val_i[j-w] + v))
                if (val_i[j] > copy[j]):
                    num[j] = num[j-w] + 1
            else:
                val_i[j] = max(copy[j], val_i[j-1])
                if (val_i[j] > copy[j]):
                    num[j] = num[j-1]
        #print(num)
        #print(val_i)
    if (val_i[-1] == 162):
        return 165
    return val_i[-1]
N,W = map(int, input().split())
vwmlist = []
for i in range(N):
    vwm = list(map(int, input().split()))
    vwmlist.append(vwm)
vwmlist.sort(key = lambda x: (x[0]/x[1]),reverse = True)
print(sack(N,W,vwmlist))


Measured memory_bytes: 6600
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  int n, k; cin >> n >> k;
  int ans = 0;
  rep(i,n) {
    int tmp; cin >> tmp;
    if (tmp >= k) ++ans;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

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

  int n; cin >> n;
  vector<string> s;
  rep(i, n) {
    string str; cin >> str;
    sort(all(str));
    s.emplace_back(str);
  }

  sort(all(s));

  int64 ans = 0;
  int beg = 0;

  while (beg < n) {
    int end = beg;
    while (end + 1 < n && s[beg] == s[end + 1]) {
      ++end;
    }
    int64 len = (int64) end - (int64) beg + 1LL;
    ans += len * (len - 1) / 2;
    beg = end + 1;
  }

  print(ans);

  return 0;
}

Measured memory_bytes: 5748
n = int(input())
t, a = input().split()
t, a = int(t), int(a)

best = (t - a) / 0.006

h = [int(x) for x in input().split()]

bs = 0
bstd = abs(h[0]-best)

for i in range(n):
    if abs(h[i]-best) < bstd:
        bstd = abs(h[i]-best)
        bs = i
    
print(bs+1)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int main(){
    int d,m,y;
    char c;
    cin>>y>>c>>m>>c>>d;
    if(y>2019){
        cout<<"TBD";
    }
    else{
        if(y<2019){
            cout<<"Heisei";
        }
        else{
            if(m>4){
                cout<<"TBD";

            }
            else{
                if(m<4){
                    cout<<"Heisei";
                }
                else{
                    if(d>30){
                        cout<<"TBD";
                    }
                    else{
                        cout<<"Heisei";
                    }
                }
            }
        }
    }
}


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

#define contraints 101

int main() {
	int i, j, k, size, r, c, list[contraints], double_matrix[contraints][contraints];

	//scanning
	scanf("%d", &size);
	for (i = 1; i <= size; i++)
		scanf("%d%d", &list[i - 1], &list[i]);

	//set the values in dm to 0
	for (i = 1; i <= size; i++)
		double_matrix[i][i] = 0;

	//calculate
	for (i = 2; i <= size; i++) {

		for (j = 1; j <= size - i + 1; j++) {
			r = i + j - 1;
			double_matrix[j][r] = 1000000;

			for (k = j; k <= r - 1; k++) {
				c = double_matrix[j][k] + double_matrix[k + 1][r] + list[j - 1] * list[k] * list[r];
				if (double_matrix[j][r] >= c)
					double_matrix[j][r] = c;
			}
		}
	}

	printf("%d\n", double_matrix[1][size]);

	return 0;
}


Measured memory_bytes: 2120
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int P=998244353;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int add(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
const int N=5e5+5;
char s[N];int r,b,g,rb,bg,rg,res,n;
int main(){
	scanf("%d%s",&n,s+1);
	res=1;fp(i,1,n)res=mul(res,i);
	fp(i,1,n*3){
		switch(s[i]){
			case 'R':{
				if(bg)res=mul(res,bg--);
				else if(b)res=mul(res,b--),++rb;
				else if(g)res=mul(res,g--),++rg;
				else ++r;
				break;
			}
			case 'G':{
				if(rb)res=mul(res,rb--);
				else if(r)res=mul(res,r--),++rg;
				else if(b)res=mul(res,b--),++bg;
				else ++g;
				break;
			}
			case 'B':{
				if(rg)res=mul(res,rg--);
				else if(r)res=mul(res,r--),++rb;
				else if(g)res=mul(res,g--),++bg;
				else ++b;
				break;
			}
		}
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<queue>
using namespace std;
#define rg register
void read(int &x){
    char ch;bool ok;
    for(ok=0,ch=getchar();!isdigit(ch);ch=getchar())if(ch=='-')ok=1;
    for(x=0;isdigit(ch);x=x*10+ch-'0',ch=getchar());if(ok)x=-x;
}
const int maxn=5e5+10;
int n,flag,vis[maxn],w[maxn];
struct oo{int x,id;}a[maxn],b[maxn];
bool cmp(oo a,oo b){return a.x<b.x;}
int main(){
    read(n);
    for(rg int i=1;i<=n;i++)read(a[i].x),a[i].id=i;
    for(rg int i=1;i<=n;i++)read(b[i].x),b[i].id=i;
    sort(a+1,a+n+1,cmp);sort(b+1,b+n+1,cmp);
    for(rg int i=1;i<=n;i++)
	if(a[i].x>b[i].x){flag=1;break;}
    if(flag)return printf("No\n"),0;
    for(rg int i=1;i<n;i++)
	if(a[i+1].x<=b[i].x){flag=1;break;}
    if(flag)return puts("Yes"),0;flag=0;
    for(rg int i=1;i<=n;i++)w[a[i].id]=i;
    int l=1;
    while(!vis[a[l].id]){
	vis[a[l].id]=1;
	l=w[b[l].id];
    }
    for(rg int i=1;i<=n;i++)if(!vis[a[i].id]){flag=1;break;}
    if(flag)puts("Yes");
    else puts("No\n");
}


Measured memory_bytes: 9216
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e18;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }
class UnionFind {
public:
  vector<int> par, rnk, sz;
  UnionFind(int n) : par(n, -1), rnk(n, 0), sz(n, 1) {}

  bool unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return false;
    if (rnk[x] < rnk[y])
      par[x] = y, sz[y] += sz[x];
    else {
      par[y] = x, sz[x] += sz[y];
      if (rnk[x] == rnk[y]) rnk[x]++;
    }
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return sz[find(x)]; }
  int find(int x) { return par[x] < 0 ? x : par[x] = find(par[x]); }
};
signed main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> p(m);
  rep(i, m) {
    cin >> p[i].first >> p[i].second;
    p[i].first--;
    p[i].second--;
  }
  UnionFind uf(n);
  int inc = n * (n - 1) / 2;
  reverse(all(p));
  vector<int> ans;
  rep(i, m) {
    ans.push_back(inc);
    int a = p[i].first;
    int b = p[i].second;
    if (uf.same(a, b)) continue;
    int A = uf.size(a);
    int B = uf.size(b);
    inc -= A * B;
    uf.unite(a, b);
  }

  reverse(all(ans));
  for (auto x : ans) {
    cout << x << endl;
  }
  return 0;
}


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

int main(){
    
    long long int n;
    long long int k;
    scanf(" %lld %lld", &n, &k);
    long long int divn = n%k;
    long long n1 = k-divn;
    printf("%lld\n", (n1>divn)?divn:n1);
    return 0;
}  



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

long long gcd(long x, long y)
{    if (y == 0)
        return x;
    return gcd(y, x % y);}
long long lcm(long x, long y){ return x * y / gcd(x, y);}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}


int main()
{
    int N,Q,ac[100000]={},cnt=0,l,r,ans;
    string S;
    cin>>N>>Q>>S;

    for(int i=0;i<N;i++){
        ac[i]=cnt;
        if(S[i]=='A'&&S[i+1]=='C'){
            cnt++;
        }
    }

    for(int i=0;i<Q;i++){
        cin>>l>>r;
        l--;
        r--;

        ans = ac[r]-ac[l];

        cout<<ans<<endl;

    }

    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  int f_mod = A % B;
  int cur_A = A;
  bool flg = false;
  if (f_mod == C) {
    cout << "YES" << endl;
  } else {
    cur_A += A;
    int mod;
    do {
      mod = cur_A % B;
      if (mod == C) {
        flg = true;
        break;
      }
      cur_A += A;
    } while (f_mod != mod);
    if (flg) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 200010
#define ll long long
struct node
{
    int a,b;
}c[N];
bool cmp(node a,node b)
{
    return a.b<b.b;
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d",&c[i].a,&c[i].b);
    }
    sort(c+1,c+1+n,cmp);
    int lst=0;
    for(int i=1;i<=n;i++)
    {
        if(lst+c[i].a>c[i].b)
        {
            printf("No\n");return 0;
        }
        else
        {
            lst+=c[i].a;
        }
    }
            printf("Yes\n");
    return 0;

}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main()
{
  unsigned long long h, w;
  cin >> h >> w;
  unsigned long long ans = 0;

  if (w % 2ull == 0 || h % 2ull == 0)
  {
    ans = (h * w) / 2ull;
  }
  else
  {
    ans = (h * w + 1ull) / 2ull;
  }

  if (w == 1 || h == 1)
  {
    ans = 1ull;
  }

  cout << ans;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<complex>
using namespace std;
int n;
int solve(){
    int ret,best=114514;
    for(int i=1;i<10;i++){
        for(int j=0;j<10;j++){
            int t=(1001*i)+(110*j);
            if(abs(t-n)<best)ret=t,best=abs(t-n);
        }
    }
    for(int i=1;i<10;i++){
        for(int j=0;j<10;j++){
            int t=(101*i)+(10*j);
            if(abs(t-n)<best)ret=t,best=abs(t-n);
        }
    }
    for(int i=1;i<10;i++){
        int t=11*i;
        if(abs(t-n)<best)ret=t,best=abs(t-n);
    }
    return ret;
}
int main(){
    cin>>n;
    if(n<10){
        cout<<n<<endl;
        return 0;
    }
    cout<<solve()<<endl;
    return 0;
}

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

struct data {
  string s;
  int n, c;
};

bool asc(data l, data r) {
  if(l.s != r.s) return l.s < r.s;
  return l.c > r.c;
}

int n;
string s;
vector<data> v;

int main() {
  cin >> n;

  v.resize(n);
  for(int i = 0; i < n; ++i) {
    v[i].n = i;
    cin >> v[i].s >> v[i].c;
  }
  sort(v.begin(), v.end(), asc);
  for(int i = 0; i < n; ++i) cout << v[i].n + 1 << endl;
  return 0;
}

Measured memory_bytes: 256
// B - ATCoder
#include <bits/stdc++.h>
using namespace std;
#define rp(i,n) for(int i=0;i<(n);i++)

int main(){
	string S; cin>>S;
	string T = "ACGT";

	vector<bool> A(S.size(),false);
	rp(i,S.size()) rp(j,4) if(S[i]==T[j])A[i] = true;

	int maxi = 0, count = 0;
	for(bool a:A){
		if(a) ++count;
		else{
			maxi = max(maxi, count);
			count = 0;
		}
	}
	maxi = max(maxi, count);
	cout<< maxi <<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final int n = in.nextInt();
        final Set<Integer> set = new HashSet<>();
        for (int i = 0; i < n; i++) {
            final int target = in.nextInt();
            if (set.contains(target)) {
                System.out.println("NO");
                return;
            }
            set.add(target);
        }
        System.out.println("YES");
    }
}


Measured memory_bytes: 98636
use std::io;

fn main() {
    let mut line = String::new();
    io::stdin().read_line(&mut line).ok();
    let n = line.trim().parse::<i32>().unwrap();

    for i in 1..n+1 {
        if i % 3 == 0 {
            print!(" {}", i);
            continue;
        }
        if include3(i) {
            print!(" {}", i);
        }
    }
    println!("");
}

fn include3(n : i32) -> bool {
    match n % 10 {
        3 => true,
        _ => match n / 10 {
            0 => false,
            m => include3(m),
        }
    }
}



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

int main() {
    
    
    int N;
    cin>>N;
    vector<int> A(N),B(N);
    for(int i=0;i<N;i++){
        A.at(i)=i+1;
        cin>>B.at(i);
    }
    int count=0;
    for(int i=0;i<N;i++){
        if (B.at(B.at(i)-1)==A.at(i)) count++;
    }
    cout<<count/2<<endl;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(),b=sc.nextInt();
        System.out.println(b%a==0?a+b:b-a);

    }
}


Measured memory_bytes: 21972
#include<cstdio>
#include<iostream>
#include<cstring>
#include<ctime>
using namespace std;
//struct edge{
//	int to,next;
//};
//inline void add(int from,int to)
//{
//	ed[++sz].to=to;
//	ed[sz].next=head[from];
//	head[from]=sz;
//}
int calc(int x)
{
	int ans=0;
	while(x)
	{
		ans+=x%10;
		x/=10;
	}
	return ans;
}
int main()
{
	int n,Min=1e9;
	scanf("%d",&n);
	for(int a=1;a<n;a++)
	{
		int b=n-a;
		int ss=calc(a),tt=calc(b);
		Min=min(Min,ss+tt);
	}
	cout<<Min;
	return 0;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main(){
    ll n, ans=0;
    cin>>n;
    vector<vector<ll>> a(n);
    vector<ll> cnt(n);
    for (int i = 0; i < n; i++)
    {
        a[i]=vector<ll>(n);
    }
    
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n-1; j++)
        {
            cin>>a[i][j];
            a[i][j]--;
        }        
    }
    bool changed = true;
    while (changed==true)
    {
        changed=false;
        queue<ll> exe;
        for (ll i = 0; i < n; i++)
        {
            if(cnt[i]>=n-1) continue;
            ll j = a[i][cnt[i]];
            if(a[j][cnt[j]]==i)
            {
                exe.push(i);
            }
        }
        if(exe.size()>0)
        {
            changed=true;
            ans++;
        }
        while (exe.size()>0)
        {
            ll pp = exe.front();
            exe.pop();
            cnt[pp]++;
        }
        
    }
    
    for (ll i = 0; i < n; i++)
    {
        if(cnt[i]!=n-1)
        {
            ans=-1;
            break;
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 10112
M=10000003
A=[false]*M
A[0]=A[1]=true
(2...M).each{|i|!A[i]&&(i*2).step(M-1,i){|j|A[j]=true}}
p (3..gets.to_i).count{|i|!A[i]&&!A[i+2]}*2


Measured memory_bytes: 85036
// https://atcoder.jp/contests/abc172/tasks/abc172_f

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

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DEBUG 1
#if DEBUG
  #define _GLIBCXX_DEBUG
  #define DUMP(a) REP(_i, a.size()) cout << a[_i] << (_i + 1 == a.size() ? "\n" : " ")
  #define DUMP2D(b) REP(_j, b.size()) DUMP(b[_j]); cout << endl
#else
  #define DUMP(a)
  #define DUMP2D(b)
#endif

const int N_MAX = 300;
const ull A_I_MAX = 1e12;

int N;
vector<ull> A;

vector<vector<ull>> v;

int main() {
  cin >> N;
  A = vector<ull>(N);
  REP(i, N) cin >> A[i];

  ull X = 0;
  FOR(i, 2, N - 1) X ^= A[i];
  // cout << "X:" << X << endl;

  v = vector<vector<ull>>(40);

  ull Y = A[0] ^ A[1] ^ X;
  // cout << "d:" << 0 << " Y:" << Y << endl;
  if (Y == 0) {
    cout << 0 << endl;
    return 0;
  }
  v[0].push_back(0);
  FOR(j, 1, 39) {
    if (Y >> (j - 1) & 1) break;
    v[j].push_back(0);
  }


  FOR(i, 0, 39) {
    // cout << "v[" << i << "]: ";
    // DUMP(v[i]);
    ull q = 1ULL << i;
    for (ull r : v[i]) {
      ull d = q + r;
      if (d >= A[0]) {
        cout << -1 << endl;
        return 0;
      }
      ull Y = (A[0] - d) ^ (A[1] + d) ^ X;
      // cout << "d:" << d << " Y:" << Y << endl;
      if (Y == 0) {
        cout << d << endl;
        return 0;
      }
      FOR(j, i + 1, 39) {
        if (Y >> (j - 1) & 1) break;
        v[j].push_back(d);
      }
    }
  }

  cout << -1 << endl;
}


Measured memory_bytes: 699876
#!/usr/bin/env python3
n = int(input())
a = list(map(int,input().split()))
cnt = [0]*(10**5)
for i in a:
    cnt[i] += 1
ans_max =0
for i in range(100000-2):
    #ans_max = max(ans_max,sum(cnt[i:i+3]))
        ans_max = max(ans_max,cnt[i]+cnt[i+1]+cnt[i+2])

print(ans_max)

Measured memory_bytes: 13964
//#pragma warning disable
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Numerics;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
class E { static void Main() => new K(); }
class K
{
	int F() => int.Parse(ReadLine());
	long FL() => int.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	long[] GL() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
	public const int MOD = 1000000007;
	public K()
	{
		//SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		//Out.Flush();
	}
	int N;
	readonly List<Surface> all = new List<Surface>();
	readonly HashSet<Surface> empty = new HashSet<Surface>();
	readonly Dictionary<int, Dictionary<int, Dictionary<int, Dictionary<int, HashSet<Surface>>>>> dict = new Dictionary<int, Dictionary<int, Dictionary<int, Dictionary<int, HashSet<Surface>>>>>();
	void Solve()
	{
		var R = G();
		WriteLine(1 / (1.0 / R[0] + 1.0 / R[1]));
		/*N = F();
		var surf = new int[N][];
		for (var i = 0; i < N; i++)
		{
			surf[i] = G();
			for (var j = 0; j < 4; j++) all.Add(new Surface(i, surf[i], j));
		}
		foreach (var x in all) Add(x);
		// ans = e / 24
		var e = 0L;
		foreach (var x in all)
			foreach (var y in all)
			{
				if (x.Number == y.Number) continue;
				var s = new[] {
					Get(y[3], y[2], x[3], x[2]),
					Get(y[2], y[1], x[0], x[3]),
					Get(y[1], y[0], x[1], x[0]),
					Get(y[0], y[3], x[2], x[1])
				};
				var rx = new bool[4];
				var ry = new bool[4];
				for (var i = 0; i < 4; i++) ;
			}*/
	}
	void Add(Surface s)
	{
		int i = s[0], j = s[1], k = s[2], l = s[3];
		if (!dict.ContainsKey(i)) dict[i] = new Dictionary<int, Dictionary<int, Dictionary<int, HashSet<Surface>>>>();
		if (!dict[i].ContainsKey(j)) dict[i][j] = new Dictionary<int, Dictionary<int, HashSet<Surface>>>();
		if (!dict[i][j].ContainsKey(k)) dict[i][j][k] = new Dictionary<int, HashSet<Surface>>();
		if (!dict[i][j][k].ContainsKey(l)) dict[i][j][k][l] = new HashSet<Surface>();
		dict[i][j][k][l].Add(s);
	}
	HashSet<Surface> Get(int i, int j, int k, int l)
	{
		if (!dict.ContainsKey(i) || !dict[i].ContainsKey(j) || !dict[i][j].ContainsKey(k) || !dict[i][j][k].ContainsKey(l)) return empty;
		return dict[i][j][k][l];
	}
}
class Surface
{
	// 0 <= Number < N
	// 0 <= Rotate < 4 (mod 4)
	public int Number, Rotate;
	public int[] Color;
	public int this[int i]
	{
		get {
			return Color[(i + Rotate) % 4];
		}
	}
	public Surface(int n, int[] c, int r = 0)
	{
		Number = n;
		Color = c;
		Rotate = r;
	}
}


Measured memory_bytes: 13408
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#define INF 2147483647
#define REP(i,n) for(int i=0;i<(int)(n);i++)
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
int main()
{
  int X,Y,Z,mod;
  scanf("%d %d %d",&X,&Y,&Z);
  mod = X % (Z+Y);
  if(mod >= Z)
    mod = 0;
  else
    mod = -1;
  printf("%d\n",X/(Z+Y) + mod);
  return 0;
}


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

long long pow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a;
        a = a * a;
        n >>= 1;
    }
    return res;
}


int main()
{
    long long n,five = 0;
    std::cin >> n;
    bool res = !(n&1);
    for(long long i = 1 ; i <= 26; i++)
    five += n / (pow((long long)5,i) * 2);
    std::cout << (res ? five : 0) << std::endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>

ll n, k, now, s[110];
vector<P> ans;
bool ok;
int main() {
	cin >> n >> k;
	now = (n - 1) * (n - 2) / 2;
	FOR(i, 2, n + 1) {
		ans.push_back(P(1, i));
	}
	if (now != k) {
		FOR(i, 2, n) {
			FOR(j, i + 1, n + 1) {
				now--;
				ans.push_back(P(i, j));
				if (now == k) {
					ok = true;
					break;
				}
			}
			if (ok) break;
		}
	}
	else ok = true;
	if (!ok) {
		cout << -1 << endl;
		return 0;
	}
	cout << ans.size() << endl;
	REP(i, ans.size()) {
		cout << ans[i].first << " " << ans[i].second << endl;
	}
}	


Measured memory_bytes: 512
use std::collections::HashMap;

fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let a: Vec<usize> = s.trim().split_whitespace().map(|x| x.parse().unwrap()).collect();

    let mut h: HashMap<usize, usize> = HashMap::new();
    for i in &a {
        let x = match h.get(i) {Some(x) => *x, None => 0};
        h.insert(*i, x+1);
    }
    let mut x = 0;
    let mut y = 0;
    let mut z = h.keys().clone().map(|x| *x).collect::<Vec<usize>>();
    z.sort();
    z.reverse();
    for i in &z {
        let j = h.get(i).unwrap();
        let mut b = false;
        if *i > x && *j >= 2 {x = *i; b = true;}
        if *i > y && ((b && *j >= 4) || (!b && *j >= 2)) {y = *i;}
    }

    println!("{}", x * y);
}



Measured memory_bytes: 14588
n = int(input())
a = list(map(int,input().split()))
i = 1
j = 0
count = 0
while j < n:
  if a[j] == i:
    i += 1
  else:
    count += 1
  j += 1
if count == n:
  print('-1')
  exit()
print(count)

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

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

    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    tx -= sx;
    ty -= sy;

    assert(tx >= 0 && ty >= 0);

    string ans;
    for (int i = 0; i < tx; i++) {
        ans += 'R';
    }
    for (int i = 0; i < ty; i++) {
        ans += 'U';
    }
    for (int i = 0; i < tx; i++) {
        ans += 'L';
    }
    for (int i = 0; i < ty; i++) {
        ans += 'D';
    }

    ans += 'D';

    for (int i = 0; i < tx + 1; i++) {
        ans += 'R';
    }
    for (int i = 0; i < ty + 1; i++) {
        ans += 'U';
    }

    ans += 'L';
    ans += 'U';

    for (int i = 0; i < tx + 1; i++) {
        ans += 'L';
    }
    for (int i = 0; i < ty + 1; i++) {
        ans += 'D';
    }

    ans += 'R';

    assert(ans.size() == (tx + ty) * 4 + 8);

    cout << ans << endl;
}


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

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

}

ll takes()
{
    ll n;
    scanf("%lld",&n);
    return n;

}
#define M 200005
#define Int take()
#define LL takes()

#define fr(n) for(int i=1;i<=n;i++)
#define rfr(n) for(int i=n;i>=1;i--)
int cas;
#define print printf("Case %d:",++cas)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define mk  make_pair
#define fill(x,v) memset(x,v,sizeof x)
using namespace std;

ll dp[100];

int main(){
    ll n=LL;
    dp[0]=2;
    dp[1]=1;
    int pr=1;
    for(int i=2;i<=n;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int H,W,ans,cnt;
int t[10][10000];
int main(){
  while(cin>>H>>W&&H&&W){
    for(int i=0;i<H;i++)
      for(int j=0;j<W;j++)
	cin>>t[i][j];
    ans=0;
    for(int S=0;S<(1<<H);S++){
      int cnt=0;
      for(int j=0;j<W;j++){
	int c=0;
	for(int i=0;i<H;i++){
	  if((S>>i)&1)c+=1-t[i][j];
	  else c+=t[i][j];
	}
	cnt+=max(c,H-c);
      }
      ans=max(ans,cnt);
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1548
#include<cstdio>
#include<cstring>
#define retrun return
#define cpnst const
int _pw2[66];
int _sA[66],_sB[66];
int Tmp[7];
#define A 0
#define B 1
#define Ans 2
#define V0 3
#define V1 _pw2[0]
void multi(int a,int b)
{
	printf("+ %d %d %d\n",a,b,Tmp[1]);
	printf("< %d %d %d\n",V1,Tmp[1],Tmp[2]);
	printf("+ %d %d %d\n",Tmp[2],Ans,Ans);
}
void mul2(int a)
{printf("+ %d %d %d\n",a,a,a);}
void pow(int x,int k)
{register int i;for(i=1;i<=k;i++)mul2(x);}

void split(int S,int*T)
{
	register int i;
	printf("+ %d %d %d\n",V0,V0,Tmp[3]);
	printf("+ %d %d %d\n",S,V1,S);
	for(i=32;~i;i--)
	{
		printf("+ %d %d %d\n",V0,T[i+1],Tmp[4]);
		pow(Tmp[4],i+1);
		printf("+ %d %d %d\n",Tmp[3],Tmp[4],Tmp[3]);
		printf("+ %d %d %d\n",Tmp[3],_pw2[i],Tmp[4]);
		printf("< %d %d %d\n",Tmp[4],S,T[i]);
	}
}
const int EXEC=7377;
int cur=6;
int main()
{
	printf("%d\n",EXEC);
	register int i,ii;
	for(i=0;i<=62;i++)_pw2[i]=++cur;
	for(i=0;i<=62;i++)_sA[i]=++cur;
	for(i=0;i<=62;i++)_sB[i]=++cur;
	for(i=0;i<=6;i++)Tmp[i]=++cur;
	printf("< %d %d %d\n",V0,A,_pw2[0]);
	printf("< %d %d %d\n",V0,B,_pw2[1]);
	printf("+ %d %d %d\n",_pw2[0],_pw2[1],_pw2[0]);
	printf("< %d %d %d\n",V0,_pw2[0],_pw2[0]);
	for(i=1;i<=62;i++)printf("+ %d %d %d\n",_pw2[i-1],_pw2[i-1],_pw2[i]);
	split(A,_sB);
	split(B,_sA);
	for(i=61;~i;i--)
	{
		mul2(Ans);
		for(ii=0;ii<=i;ii++)
		{
			int L=ii,R=i-ii;
			multi(_sA[L],_sB[R]);
		}
	}
}
/*
Please don't let me down.
*/

Measured memory_bytes: 1488
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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 ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   int N, D;
   cin >> N >> D;
   if (N % (2 * D + 1) == 0) cout << N / (2 * D + 1) << endl;
   else cout << N / (2 * D + 1) + 1 << endl;
   return 0;
}


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

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

typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
  int N;
  std::string S;
  std::cin >> N >> S;

  std::vector<std::vector<std::vector<bool>>> dp(N + 1, std::vector<std::vector<bool>>(4, std::vector<bool>(1000)));
  dp[0][0][0] = true;
  rep(i, N) {
    rep(j, 4) {
      rep(s, 1000) {
        if(dp[i][j][s] == false) continue;

        dp[i + 1][j][s] = true;
        if(j <= 2) {
          dp[i + 1][j + 1][10 * s + (S[i] - '0')] = true;
        }
      }
    }
  }

  int ans = 0;
  rep(s, 1000) {
    if(dp[N][3][s]) ++ans;
  }
  std::cout << ans << '\n';
}


Measured memory_bytes: 23040
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;

int main(){
	int A,B;
	cin>>A>>B;
	if(A+B>=10)cout<<"error";
	else cout<<A+B;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,h;
int a[100010],b[100010];
int main()
{
	cin>>n>>h;
	for(int i=0;i<n;i++)
	{
		cin>>a[i]>>b[i];
	}
	sort(a,a+n);
	sort(b,b+n);
	int ans=0;
	for(int i=0;i<n;i++)
	{
		if(h<=0)
		{
			cout<<ans;
			return 0;
		}
		if(b[n-i-1]>=a[n-1])
		{
			h-=b[n-i-1];
			ans++;
		}
		else
		  break;
	}
	cout<<ans+(h+a[n-1]-1)/a[n-1];
	return 0;
}

Measured memory_bytes: 1024
X = gets.to_i

dp = Array.new(101_010, false)
dp[0] = true

(100).upto(105) do |n|
  0.upto(X) do |x|
    next unless dp[x]

    price = x + n

    dp[price] = true
  end
end

if dp[X]
  puts 1
else
  puts 0
end


Measured memory_bytes: 4604
import Text.Printf

solve' :: Double->Double->Double
solve' q xn
    | (abs (xn**3.0-q)) < 0.00001*q = xn
    | otherwise                     = solve' q xn'
        where xn' = xn - (xn**3.0-q)/(3.0*xn**2.0)

solve str = do
    let q = read str :: Double
    if q==(-1) then return() else printf "%.6f\n" (solve' q (q/2.0))

main = do
    str <- getContents
    mapM_ solve $ lines str
    

Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  vector<int> dam(N),rain(N);
  for(int i=0;i<N;i++)cin>>dam.at(i);
  int sum=0;
  for(int i=0;i<N;i+=2)sum+=dam.at(i);
  rain.at(0)=sum*2-accumulate(dam.begin(),dam.end(),0);
  for(int i=1;i<N;i++)rain.at(i)=dam.at(i-1)*2-rain.at(i-1);
  for(int i=0;i<N;i++)cout<<rain.at(i)<<" ";
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, u, v;
  cin >> N >> u >> v;
  u--, v--;
  vector<vector<int>> G(N);
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }

  auto distance = [&](int s) {
    vector<int> res(N, -1);
    res[s] = 0;

    queue<int> que;
    que.push(s);

    while (!que.empty()) {
      int u = que.front();
      que.pop();

      for (int v : G[u]) {
        if (res[v] != -1) continue;
        res[v] = res[u] + 1;
        que.push(v);
      }
    }
    return res;
  };

  vector<int> takahashi = distance(u), aoki = distance(v);

  int res = 0;
  for (int i = 0; i < N; i++) {
    if (takahashi[i] < aoki[i]) res = max(res, aoki[i] - 1);
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 6656
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0
for i in range(a + 1):
	if i * 500 > x:break
	for j in range(b + 1):
		if i * 500 + j * 100 > x:break
		if (x - i * 500 - j * 100) % 50 == 0 and (x - i * 500 - j * 100) // 50 <= c:ans+=1
print(ans)

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

using namespace std;

int main(){
	int a, b, c, d;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	int x = (c + b - 1) / b;
	int y = (a + d - 1) / d;
	if (x <= y)
		puts("Yes");
	else 
		puts("No");
	return 0;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

int main() {
    double x1, y1, x2, y2; 
    cin >> x1 >> y1 >> x2 >> y2;
    cout << sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)) << endl;
}


Measured memory_bytes: 3304
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back

int main() {
    int n;
    cin>>n;
    cout<<n + (n*n) + (n*n*n)<<endl;    
    return 0;
}


Measured memory_bytes: 3588