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

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		if(s.equals( "a")) {
			System.out.println("b");
		}else if(s.equals( "b")) {
			System.out.println("c");
		}else if(s.equals( "c")) {
			System.out.println("d");
		}else if(s.equals( "d")) {
			System.out.println("e");
		}else if(s.equals( "e")) {
			System.out.println("f");
		}else if(s.equals( "f")) {
			System.out.println("g");
		}else if(s.equals( "g")) {
			System.out.println("h");
		}else if(s.equals( "h")) {
			System.out.println("i");
		}else if(s.equals( "i")) {
			System.out.println("j");
		}else if(s.equals( "j")) {
			System.out.println("k");
		}else if(s.equals( "k")) {
			System.out.println("l");
		}else if(s.equals( "l")) {
			System.out.println("m");
		}else if(s.equals( "m")) {
			System.out.println("n");
		}else if(s.equals( "n")) {
			System.out.println("o");
		}else if(s.equals( "o")) {
			System.out.println("p");
		}else if(s.equals( "p")) {
			System.out.println("q");
		}else if(s.equals( "q")) {
			System.out.println("r");
		}else if(s.equals( "r")) {
			System.out.println("s");
		}else if(s.equals( "s")) {
			System.out.println("t");
		}else if(s.equals( "t")) {
			System.out.println("u");
		}else if(s.equals( "u")) {
			System.out.println("v");
		}else if(s.equals( "v")) {
			System.out.println("w");
		}else if(s.equals( "w")) {
			System.out.println("x");
		}else if(s.equals( "x")){
			System.out.println("y");
		}else {
			System.out.println("z");
		}
	}
}


Measured memory_bytes: 21844
#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;
int h, w, x;
char p[50 + 5][50 + 5];
int d[50 + 5][50 + 5];
struct Node {
	int r, c;
	Node(int r,int c):r(r),c(c){}
};
const int dr[] = { 0,-1,0,1 };
const int dc[] = { 1,0,-1,0 };

bool ok(int i,int j) {
	if (i < 0 || j < 0 || i >= h || j >= w)return false;
	return p[i][j] == '.'&&d[i][j] == 0;
}

int main() {
	scanf("%d%d", &h, &w);//要到h-1,w-1
	memset(p, 0, sizeof(p));
	memset(d, 0, sizeof(d));
	for (int i = 0;i < h;i++)scanf("%s", p[i]);
	if (p[0][0] == '#' || p[h - 1][w - 1] == '#') { printf("-1");return 0; }
	queue<Node> q;
	q.push(Node(0, 0));
	d[0][0] = 1;
	while (!q.empty()) {
		struct Node t = q.front();q.pop();
		for (int i = 0;i < 4;i++)if (ok(t.r + dr[i], t.c + dc[i])) {
			if (t.r + dr[i] == h - 1 && t.c + dc[i] == w - 1) { x = d[t.r][t.c] + 1;goto A; }
			d[t.r + dr[i]][t.c + dc[i]] = d[t.r][t.c] + 1;
			q.push(Node(t.r + dr[i], t.c + dc[i]));
		}
	}
	printf("-1");
	return 0;
	A:
		int cnt = 0;
		for (int i = 0;i < h;i++)for (int j = 0;j < w;j++)if (p[i][j] == '.')cnt++;
		printf("%d", cnt - x);
	return 0;
}

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

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int x, y, z;
    cin >> x >> y >> z;

    cout << z << " " << x << " " << y << "\n";

    return 0;
}



Measured memory_bytes: 256
using System;
using System.Linq;

namespace Testcode
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                if (x[0] == 0 && x[1] == 0)
                {
                    break;
                }
                for (int h = 0; h < x[1]; h++)
                {
                    Console.Write("#");
                }
                Console.WriteLine();

                for (int i = 2; i < x[0]; i++)
                {
                    Console.Write("#");
                    for (int I = 2; I < x[1]; I++)
                    {
                        Console.Write(".");
                    }
                    Console.Write("#");
                    Console.WriteLine();
                }
                for (int j = 0; j < x[1]; j++)
                    {
                        Console.Write("#");
                    }
                    Console.WriteLine();
                
                Console.WriteLine();
            }
        }
    }
}



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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 1001

typedef pair <pi,int> pii;

int H,W;
bool vis[maxn][maxn];
char grid[maxn][maxn];
pi st,en;
bool ingrid(pi i){
	return (i.f >= 1 && i.f <= H && i.s >= 1 && i.s <= W);
}
int dx[] = {0,0,-1,1};
int dy[] = {-1,1,0,0};

int main(){
	fast;
	
	cin>>H>>W;
	
	cin>>st.f>>st.s>>en.f>>en.s;
	
	FOR(i,1,H) FOR(j,1,W) cin>>grid[i][j];
	
	deque <pii> q;
	q.push_front(pii(st,0));
	
	while (!q.empty()){
		pii cur = q.front(); q.pop_front();
		
		if (vis[cur.f.f][cur.f.s]) continue;
		vis[cur.f.f][cur.f.s] = 1;
		
		if (cur.f == en){
			cout<<cur.s;
			return 0;
		}
		FOR(i,0,3){
			int nx = cur.f.f + dx[i], ny = cur.f.s + dy[i];
			if (ingrid(pi(nx,ny)) && grid[nx][ny] != '#') q.push_front(pii(pi(nx,ny),cur.s));
		}
		
		FOR(i,-2,2) FOR(j,-2,2){
			int nx = cur.f.f + i, ny = cur.f.s + j;
			if (ingrid(pi(nx,ny)) && grid[nx][ny] != '#') q.push_back(pii(pi(nx,ny),cur.s + 1));
		}
	}
	cout<<-1;
			
	
}


Measured memory_bytes: 8852
import itertools
import numpy as np
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
A = np.array(A)
ans = 0
for i in list(itertools.product([0,1,-1],repeat=N)):
    if np.prod(A + np.array(i)) % 2 == 0:
        ans += 1
print(ans)

Measured memory_bytes: 22508
#include <iostream>
#include <algorithm>

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

#ifdef DEBUG_ON
    freopen("input", "r", stdin);
#endif

    int candies[3];
    std::cin >> candies[0] >> candies[1] >> candies[2];
    std::sort(candies, candies + 3);
    std::cout << (candies[0] + candies[1] == candies[2] ? "Yes" : "No") << '\n';
    return 0;
}

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

int main()
{
  long long n;
  cin >> n;
  long long i;
  long long ans = 0;
  for(i = 1; i < sqrt(n); i++)
  {
    if(n%i == 0 && n/i - 1 > sqrt(n))
    {
      ans += n/i - 1;
    }
  }
  cout << ans << endl;
}

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

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

using namespace std;
typedef long long ll;
const int mod = 1000000007;


int main() {
    int n, d;
    cin >> n >> d;
    int x[11][11];
    rep(i,n)rep(j,d) cin >> x[i][j];
    int ans = 0;
    rep(i,n-1) {
        Rep(j,i+1,n) {
            int s = 0;
            rep(l, d) {
                int dx = x[i][l] - x[j][l];
                s += dx*dx;
            }
            float dist = sqrt(s);
            if (ceil(dist) == floor(dist)) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main(void){
 
  /* 文字列 */
  string s1,s2,s3;
 
  /* 英数字を入力 */
  cin>>s1>>s2>>s3;
  string YON="NO";
  
  if(s1[s1.length()-1]==s2[0]&&s2[s2.length()-1]==s3[0]){
        YON="YES";
  }
  cout<<YON<<endl;
  
 
}


Measured memory_bytes: 256
<?php
//error_reporting(0);
$N = trim(fgets(STDIN));
$S = trim(fgets(STDIN));
$K = trim(fgets(STDIN));
//list($A,$B,$C) =  explode(" ",trim(fgets(STDIN)));

$t = $S[$K-1];
$l = strlen($S);
$ret = "";
for($i=0;$i<$N;$i++) {
  if ($S[$i]!=$t) {
    $ret .= "*";
  }
  else {
    $ret .= $t;
  }
}
printf("%s\n",$ret);


Measured memory_bytes: 4728
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n, a = sc.nextInt()
  val x = Array.fill(n)(sc.nextInt() - a)

  val dp = Array.fill(n+1, 5001)(-1L)
  for (j <- 0 to 5000) {
    dp(0)(j) = 0
  }
  dp(0)(2500) = 1

  def solve(i: Int, j: Int): Long = {
    if (dp(i)(j) != -1) {
      dp(i)(j)
    } else {
      val ans = solve(i-1, j) + solve(i-1, j - x(i-1))
      dp(i)(j) = ans
      ans
    }
  }

  println(solve(n, 2500) - 1)
}


Measured memory_bytes: 55536
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;

string S[200];
bool used[200];
int level[200];
int main(){ 
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> S[i];
    }

    int ans = 0;
    bool found = false;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            used[j] = false;
            level[j] = -1;
        }

        queue <pair<int, int> > q;
        q.push(make_pair(i, 0));
        bool possible = true;
        used[i] = true;
        level[i] = 0;
        while(!q.empty()){
            auto tmp = q.front();
            int cur = tmp.first;
            int cur_level = tmp.second;
            q.pop();
            for(int next = 0; next < S[cur].size(); next++){
                if(S[cur][next] != '1'){
                    continue;
                }
                if(used[next] && level[next] == cur_level){
                    possible = false;
                    break;
                }
                if(!used[next]){
                    used[next] = true;
                    level[next] = cur_level + 1;
                    q.push(make_pair(next, cur_level + 1));
                }
            }
            if(!possible){
                break;
            }
        }
        if(possible){
            found = true;
            ans = max(ans, *max_element(level, level + N) + 1);
        }
    }

    if(!found){
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

typedef char* String;

String string_input(void){
    int i,len;
    char buf[100001];
    String str;
    scanf("%s",buf);//buf=入力した文字列が入るchar型の配列
    
    len=strlen(buf);//len=文字列の長さを表すint型変数
    NEW(str,len+1);//strはただのポインタだから、ここでNEWを使ってメモリを確保しなくちゃいけない
    for(i=0;i<len;i++){
        str[i]=buf[i];
    }
    str[len]=0;
    
    return str;
}

int main(void){
    String S=string_input();
    int N=strlen(S);

    for(int i=0;i<N-1;i++){
        if(S[i]==S[i+1]){
            printf("%d %d\n",i+1,i+2);
            return 0;
        }
    }
    for(int i=0;i<N-2;i++){
        if(S[i]==S[i+2]){
            printf("%d %d\n",i+1,i+3);
            return 0;
        }
    }

    printf("-1 -1\n");
    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Stack;


class Main{
	public static void main(String[] args){
		Solve s = new Solve();
		s.solve();
	}	
}

class Solve{
	Solve(){}
	
	Scanner in = new Scanner(System.in);

	void solve(){
		while(in.hasNext()){
			int n = in.nextInt();
			if(n == 0) return;
			int ap = 0, ad = 0;
			for(int i = 0; i < n; i++){
				int p = in.nextInt(), d = in.nextInt() + in.nextInt();
				if(d > ad) {
					ap = p;
					ad = d;
				}
			}
			System.out.print(ap);
			System.out.print(" ");
			System.out.println(ad);
		}
	}

	

}

Measured memory_bytes: 161768
#include<stdio.h>
#include<string.h>
int main(void){
    int n, i, j, T, H, Ba, turn, Tcount, Hcount, flag, Tcard[1000] = { 0 }, Hcard[1000] = { 0 }, key;
    scanf("%d", &n);
    while ( n ) {
        Tcount = Hcount = turn = Ba = 0;
        for ( i = 0; i < n; i++ ){
            scanf("%d", &Tcard[i]);
        }
        flag = 1;
        while (flag) {
            flag = 0;
            for ( i = n - 1; i > 0; i-- ) {
                if ( Tcard[i] < Tcard[i - 1]) {
                    flag = 1;
                    key = Tcard[i];
                    Tcard[i] = Tcard[i - 1];
                    Tcard[i - 1] = key;
                }
            }
        }
        T = H = 0;
        for ( i = 1; i <= 2 * n; i++ ) {
            if ( Tcard[T] == i ) T++;
            else if ( Tcard[T] != i) {Hcard[H] = i; H++;}
        }
        /*for ( i = 0; i < n; i++ ) printf("%d ", Tcard[i]);printf("\n");
        for ( i = 0; i < n; i++ ) printf("%d ", Hcard[i]);printf("\n");*/
        while (1) {
            if ( turn == 0 ) {
                for ( i = 0; i < n; i++ ) {
                    turn = 1;
                    if ( Tcard[i] > Ba ) {
                        Ba = Tcard[i];
                        for ( j = i ; j < n; j++ ) {
                            Tcard[j] = Tcard[j + 1];
                        }                        
                        break;
                    }
                }
                if ( i == n ) Ba = 0;
            } else if ( turn == 1 ) {
                for ( i = 0; i < n; i++ ) {
                    turn = 0;
                    if ( Hcard[i] > Ba ) {
                        Ba = Hcard[i];
                        for ( j = i ; j < n; j++ ) {
                            Hcard[j] = Hcard[j + 1];
                        }                        
                        break;
                    }
                }
                if ( i == n ) Ba = 0;
            }
            if ( Tcard[0] == 0 || Hcard[0] == 0) break;
            /*printf("ba:%d\n", Ba);
            for ( i = 0; i < n; i++ ) printf("%d ", Tcard[i]);printf("\n");
            for ( i = 0; i < n; i++ ) printf("%d ", Hcard[i]);printf("\n");*/
        }
        /*for ( i = 0; i < n; i++ ) printf("%d ", Tcard[i]);printf("\n");
        for ( i = 0; i < n; i++ ) printf("%d ", Hcard[i]);printf("\n");*/
        for ( i = 0; i < n; i++ ) {
            if ( Tcard[i] != 0 ) Tcount++;
            if ( Hcard[i] != 0 ) Hcount++;
            if ( Tcard[0] == 0 && Hcard[0] == 0) break;
        }
        printf("%d\n%d\n", Hcount, Tcount);
        scanf("%d", &n);
    }
    return 0;
}

Measured memory_bytes: 1744
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>

#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>

using namespace std;

int main()
{
    int64_t N, x;
    std::cin >> N >> x;

    std::vector<int64_t> a;
    for (int64_t i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;
        a.push_back(t);
    }

    // 貪欲法
    // 前から確認して聴き、今後影響の有るはずの先のキャンディを
    // 優先して取る
    size_t count = 0;
    for (int64_t i = 1; i < N; ++i) {
        auto over = a[i-1] + a[i] - x;
        if (over > 0) {
            if (over >= a[i]) {
                a[i-1] -= (over - a[i]);
                a[i] = 0;
            }
            else {
                a[i] -= over;
            }
            count += over;
        }
    }

    std::cout << count << std::endl;

    return 0;
}


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

using namespace std;
typedef pair<int, int> ii;

bool comp(pair<ii, int> a, pair<ii, int> b) {
    return a.first.first + a.first.second > b.first.first + b.first.second;
}


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

    pair<ii, int> arr[n];

    for(int i = 0; i < n; ++i) {
        int w, s, v; cin >> w >> s >> v;
        arr[i] = pair<ii, int>(ii(w, s), v);
    }
    sort(arr, arr + n, comp);

    vector<long long> dp(20004);


    for(int i = n-1; i >= 0; --i) {

        for(int j = min(arr[i].first.second, 20001 - arr[i].first.first); j >= 0; --j) {

            dp[j + arr[i].first.first] = max(dp[ j + arr[i].first.first] , dp[j] + arr[i].second);
        }
    }

    long long ans = 0;

    for(int i = 0; i <= 20001; ++i) {
        ans = max(ans, dp[i]);
    }
    cout << ans;



}

Measured memory_bytes: 384
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	int A[2001];
	ld bunbo=0;
	scan(N);
	rep(i,N){
		scan(A[i]);
		bunbo+=1.0/A[i];
	}
	prin(setprecision(10)<<1.0/bunbo);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;

using namespace std;

const long long INF = 1e18;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

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

	int n, s;
	cin >> n >> s;
	int* a = new  int[n];
	rep(i, n) cin >> a[i];

	ll* dp = new ll[s + 1];
	memset(dp, 0, sizeof(ll)*(s + 1));

	ll ans = 0;
	rep(i, n) {
		RREP(j, a[i], s) {
			dp[j] += dp[j - a[i]];
			dp[j] %= MOD;
		}

		++dp[0];
		++dp[a[i]];

		ans += dp[s];
		ans %= MOD;
	}

	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 256
def check(x, y):
    for a, b in zip(x, y):
        if a != b and b != -1:
            return False
    else:
        return True


n = int(input())
remarks = []
cnt_max = 0
for _ in range(n):
    a = int(input())
    x = [tuple(map(int, input().split())) for i in range(a)]
    r = [-1] * n
    for i, j in x:
        r[i - 1] = j
    remarks.append(r)
for r in range(2 ** n):
    r = list(bin(r)[2:].zfill(n))
    r = [int(i) for i in r[:]]
    cnt = 0
    for i in range(n):
        if r[i] == 1:
            flag = check(r, remarks[i])
            cnt += 1
            if not flag:
                cnt = 0
                break
    cnt_max = max(cnt, cnt_max)
print(cnt_max)

Measured memory_bytes: 3064
using System;

class Program
{
    static void Main()
    {
        long n = long.Parse(Console.ReadLine());
        int ans = int.MaxValue;
        for (int i = 1; i <= Math.Sqrt(n); i++)
        {
            if (n % i == 0)
            {
                long L = n / i;
                ans = Math.Min(ans, L.ToString().Length);
            }
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 11092
/*
安定なソート
*/
package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"log"
	"os"
	"strconv"
	"strings"
)

type card struct {
	suit  string
	value int
}

type cards []card

func (s cards) String() string {
	var buf bytes.Buffer
	sep := ""
	for _, v := range s {
		buf.WriteString(fmt.Sprintf("%s%s%d", sep, v.suit, v.value))
		sep = " "
	}
	return buf.String()
}
func eGetCards(r *bufio.Reader) []card {
	line := eGetLine(r)
	fields := strings.Split(line, " ")
	var cards []card
	for _, f := range fields {
		sv := strings.Split(f, "")
		cards = append(cards, card{sv[0], eAtoi(sv[1])})
	}
	return cards
}

func bubbleSort(a cards) {
	sorted := 0
	for sorted < len(a)-1 {
		for cur := len(a) - 1; cur > sorted; cur-- {
			if a[cur-1].value > a[cur].value {
				// 左隣の方が大きいので入れ替える.
				v := a[cur]
				a[cur] = a[cur-1]
				a[cur-1] = v
			}
		}
		sorted++
	}
}
func selectionSort(a cards) {
	for sorted := 0; sorted < len(a)-1; sorted++ {
		// ソートしていない部分から最小値を探す
		i := sorted + 1
		mini := i
		for ; i < len(a); i++ {
			if a[i].value < a[mini].value {
				mini = i
			}
		}
		// 入れ替える
		if a[mini].value < a[sorted].value {
			v := a[sorted]
			a[sorted] = a[mini]
			a[mini] = v
		}
	}
}

func isStable(in, out []card) bool {
	for i := 0; i < len(in); i++ {
		if in[i].suit != out[i].suit {
			return false
		}
	}
	return true
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	eGetInt(reader)
	a := eGetCards(reader)
	b := make([]card, len(a))
	copy(b, a)

	bubbleSort(a)
	fmt.Println(cards(a))
	fmt.Println("Stable")

	selectionSort(b)
	fmt.Println(cards(b))
	if isStable(a, b) {
		fmt.Println("Stable")
	} else {
		fmt.Println("Not stable")
	}
}
func eGetLine(r *bufio.Reader) string {
	s, err := r.ReadString(byte('\n'))
	if err != nil {
		if err != io.EOF {
			log.Fatal(err.Error())
		}
		return s
	}
	return strings.TrimRight(s, "\r\n")
}
func eGetInt(r *bufio.Reader) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInts(r *bufio.Reader) []int {
	line := eGetLine(r)
	fields := strings.Split(line, " ")
	var ints []int
	for _, f := range fields {
		ints = append(ints, eAtoi(f))
	}
	return ints
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}



Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define rep3(i, s, n) for (int i = s; i > (int)(n); i--)
#define all(obj) obj.begin(), obj.end()
#define db(x) cerr << #x << ":" << x << " "
#define dbl(x) cerr << #x << ":" << x << "\n"
#define dbv(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define dbvv(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << endl; }
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
/*
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
*/

int main() {
	const int INF = 10007;
	int H, W; cin >> H >> W;
	vector<vector<bool>> m(H, vector<bool>(W)); // true=白, false =黒
	rep(i, H) {
		string s; cin >> s;
		rep(j, W) {
			m.at(i).at(j) = s.at(j) == '.';
		}
	}
	// dbvv(m);
	vector<vector<int>> dis(H, vector<int>(W, INF)); // 左上からの距離(そのマスにたどり着くために最小限必要な操作の回数)
	using ti3 = tuple<int, int, int>; // (d, i, j)
	priority_queue<ti3, vector<ti3>, greater<ti3>> p;
	if (m.at(0).at(0)) {
		ti3 t(0, 0, 0); p.push(t); dis.at(0).at(0) = 0;
	} else {
		ti3 t(1, 0, 0); p.push(t); dis.at(0).at(0) = 1;
	}
	while (!p.empty()) {
		ti3 u = p.top(); p.pop();
		int d, i, j; tie(d, i, j) = u;
		if (j + 1 < W) {
			if (m.at(i).at(j) && !m.at(i).at(j + 1)) {
				if (dis.at(i).at(j + 1) > d + 1) {
					ti3 v(d + 1, i, j + 1); p.push(v); dis.at(i).at(j + 1) = d + 1;
				}
			} else {
				if (dis.at(i).at(j + 1) > d) {
				ti3 v(d, i, j + 1); p.push(v); dis.at(i).at(j + 1) = d;
				}
			}
		}
		if (i + 1 < H) {
			if (m.at(i).at(j) && !m.at(i + 1).at(j)) {
				if (dis.at(i + 1).at(j) > d + 1) {
				ti3 v(d + 1, i + 1, j); p.push(v); dis.at(i + 1).at(j) = d + 1;
				}
			} else {
				if (dis.at(i + 1).at(j) > d) {
				ti3 v(d, i + 1, j); p.push(v); dis.at(i + 1).at(j) = d;
				}
			}
		}
		// db(i); dbl(j);
		// dbvv(dis);
	}
	dbvv(dis);
	cout << dis.at(H - 1).at(W - 1) << endl;
}

Measured memory_bytes: 256
import sys
import numpy as np


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


sys.setrecursionlimit(10 ** 9)


def main():
    H, W = map(int, input().split())
    N = int(input())
    A = list(map(int, input().split()))
    C = np.zeros(H * W, dtype=np.int32)
    first = 0
    for i, a in enumerate(A, 1):
        C[first : first + a] = i
        first += a

    ans = C.reshape((H, W))
    ans[1::2, :] = ans[1::2, ::-1]

    for i in range(H):
        print(" ".join(ans[i].astype(str)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 12612
#include <stdio.h>
#include <math.h>
#include <iostream>

using namespace std;

int main() {

	double a;
	int i = 0;
	double MAX;
	double MIN;
	double kai;

	while(cin >> a) {
		if (i == 0) {
			MAX = a;
			MIN = a;
		} else {
			MAX = max(MAX,a);
			MIN = min(MIN,a);
		}
		i++;
	}

	kai = MAX - MIN;

	cout << kai << endl;

	return 0;
}

Measured memory_bytes: 1280
mod=10**9+7
n,m=map(int,input().split())
def mypow(a,b):
	#a**b
	if b==0:
		return 1
	res=mypow(a**2%mod,b//2)
	if b%2==0:
		return res
	else:
		return res*a%mod
print(mypow(n,m))


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
const double PI  = acos(-1.0);
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 
int main()
{

    int i;
    cin >> i;
    string S = "ACL";
    rep(ii, i){
        cout << S;
    }
    return 0;
}



Measured memory_bytes: 3624
while True:
    s=list(map(str,input().split(' ')))
    if s[1]=='X':
        break
    name=list(s[0])
    der=0
    n=[]
    for i in range(1,len(name)):
        if name[i].isupper()==True:
            n.append(i)
        if name[i]=='_':
            n.append(i-der)
            der+=1
    if s[1]=='U':
        name[0]=name[0].upper()
        for u in range(len(n)):
            if name[n[u]]=='_':
                name.pop(n[u])
                name[n[u]]=name[n[u]].upper()
        print(''.join(name))
    if s[1]=='L':
        name[0]=name[0].lower()
        for l in range(len(n)):
            if name[n[l]]=='_':
                name.pop(n[l])
                name[n[l]]=name[n[l]].upper()
        print(''.join(name))
    if s[1]=='D':
        if '_' in name:
            print(''.join(name))
        else:
            name[0]=name[0].lower()
            der=0
            for d in range(len(n)):
                name[n[d]+der]=name[n[d]+der].lower()
                name.insert(n[d]+der,'_')
                der+=1
            print(''.join(name))


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

using namespace std;

const int N = 200000 + 7;

int gcd(int a, int b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  int n;
  cin >> n;
  int a[N];
  for(int i = 1; i <= n; ++i) cin >> a[i];
  int l[N];
  int r[N];
  for(int i = 0; i <= n + 1; ++i) {
    l[i] = 0;
    r[i] = 0;
  }
  for(int i = 1; i <= n; ++i) {
    l[i] = gcd(l[i - 1], a[i]);
    //cout << l[i] << " ";
  }
  //cout << endl;
  for(int i = n; i >= 1; --i) {
    r[i] = gcd(r[i + 1], a[i]);
    //cout << r[i] << " ";
  }
  //cout << endl;
  int ans = 0;
  for(int i = 1; i <= n; ++i) {
    ans = max(ans, gcd(l[i - 1], r[i + 1]));
  }
  cout << ans << "\n";
  return 0;
}


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

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

using namespace std;

int main(){
	int a,b; cin>>a>>b;
	auto f=[](int x){ return x==1?x+13:x; };
	cout<<(f(a)==f(b)?"Draw":f(a)>f(b)?"Alice":"Bob")<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>
#include <bitset>

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

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  int H, W, N; cin >> H >> W >> N;
  if (H >= W) cout << (N + H - 1) / H << endl;
  else cout << (N + W - 1) / W << endl;
}


Measured memory_bytes: 256
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def ifn(): return float(input()) #浮動小数点読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def fmn(): return map(float, input().split()) #浮動小数点map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, input().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD

def is_prime(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

Q = iin()
lr = [iln() for _ in range(Q)]
max_v = 10**5
prime = is_prime(max_v)

c = [0 for _ in range(max_v+1)]
for i in range(max_v):
    c[i+1] = c[i]
    if i % 2 == 1 and prime[i] and prime[((i+1)//2)]: 
        c[i+1] += 1
for i in range(Q):
    l = lr[i][0]
    r = lr[i][1]
    print(c[r+1] - c[l])

Measured memory_bytes: 31900
#include<iostream>

using namespace std;

int main(){
	int b,r,g,c,s,t;
	while(1){
		cin>>b>>r>>g>>c>>s>>t;
		if(b==0&&r==0&&g==0&&c==0&&s==0&&t==0) break;
		cout<<100+b*(16*5+15)+r*(16*3+15)+g*7+c*2+s*3-t*3<<endl;
	}
}

Measured memory_bytes: 1160
package main

import (
	"fmt"
)

func main() {
	var A,B,C,X,Y int
	fmt.Scan(&A,&B,&C,&X,&Y)
	
	bigger := Max(X,Y)
	
	min := 1000000000
	for ab := 0; ab <= bigger * 2; ab += 2 {
      	a := Max((X - ab / 2),0)
      	b := Max((Y - ab / 2),0)
		sum := a * A + b * B + ab * C
     //fmt.Printf("a=%d,b=%d,ab=%d,sum=%d\n", a, b, ab, sum)
		min = Min(sum,min)
	}
	fmt.Println(min)
}

func Max(num1,num2 int) int {
	if num1 > num2 {
		return num1
	}
	return num2
}

func Min(num1,num2 int) int {
	if num1 < num2 {
		return num1
	}
	return num2
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
#define _cTime (chrono::system_clock::now())
#define progress (chrono::duration_cast<chrono::milliseconds>(_cTime-_sTime).count())
#define reset _sTime=_cTime
auto reset;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m,ans=0,cnt=0;
	cin>>n>>m;
	vector<pll> v(n);
	rep(i,n)cin>>v[i].fs>>v[i].sc;
	sort(all(v));
	rep(i,n){
		ans+=min(m-cnt,v[i].sc)*v[i].fs;
		cnt+=v[i].sc;
		if(cnt>=m){
			cout<<ans<<endl;
			return 0;
		}
	}
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<math.h>
int digit(long long int n)
{
    int f,r;
    r=log10(n);
    f=n/(pow(10,r));
    return f;
}
int main()
{
    long long int n,i,f1,c,j;
    scanf("%lld",&n);
    int a[10][10]={0};
    for(i=1;i<=n;i++)
    {
        if(i%10==0)
        {
        continue;
        }
        else
        {
            f1=digit(i);
            a[f1][i%10]++;
        }
    }
    //printf("%lld\n",f1);
    c=0;
    for(i=1;i<=9;i++)
    {
        for(j=1;j<=9;j++)
        {
        c=c+(a[i][j]*a[j][i]);
        }
    }
    printf("%lld\n",c);
    return 0;
}

Measured memory_bytes: 2516
#include"bits/stdc++.h"
using namespace std;

int main()
{
  int A;
  int B;
  cin >> A;
  cin >> B;
  
  int plug=1;
  int num_plug=0;
  
  while (plug < B) {
    plug += A-1;
    num_plug++;
  }

  cout << num_plug << endl;

  return 0;
}


Measured memory_bytes: 256
import copy
n = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(1, n - 1):
    tre_p = [p[i - 1], p[i], p[i + 1]]
    tre_p_copyed = copy.copy(tre_p)
    tre_p.remove(min(tre_p))
    if tre_p_copyed[1] == min(tre_p):
        count += 1
print(count)


Measured memory_bytes: 3444
S = input()
T = input()

q = int(input())

s = [0]*len(S)
t = [0]*len(T)
for i, x in enumerate(S):
    if x == "A":
        s[i] += 1
for i, x in enumerate(T):
    if x == "A":
        t[i] += 1

ss = [0]*(len(S)+1)
for i, x in enumerate(s):
    ss[i+1] = s[i] + ss[i]
tt = [0]*(len(T) + 1)
for i, x in enumerate(t):
    tt[i+1] = t[i]+tt[i]


for i in range(q):
    a, b, c, d = map(int, input().split())

    k = (ss[b] - ss[a-1])
    l = (tt[d] - tt[c-1])
    k += ((b - a + 1) - k)*2
    l += ((d - c + 1) - l)*2
    if abs(k-l) % 3 == 0:
        print("YES")
    else:
        print("NO")


Measured memory_bytes: 15124
#include<iostream>
#include<algorithm>
#include<vector>
#include<utility>
using namespace std;
typedef long long int ll;


int main(){

	ll n, k, a[100000], cnt[41];
	cin >> n >> k;
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	for(int i=0; i<n; i++){
		for(int j=40; 0<=j; j--){
			if(((1LL<<j) & a[i])==0){
				cnt[j]++;
			}
		}
	}
	ll total=0;
	for(int i=40; 0<=i; i--){
		if((total | (1LL << i)) <=k && n-cnt[i] <= cnt[i]){
			total |= 1LL << i;
		}
	}
	ll ans=0;
	for(int i=0; i<n; i++){
		ans+=total^a[i];
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main() {
    fastio
	ll n,t,i,j,x,k;
    cin>>n;
    
    ll a[n];
    for(i=0;i<n;i++)
    cin>>a[i];
    
    x=a[0];
    k=0;
    
    for(i=1;i<n;i++){
        if(a[i]>x) x=a[i];
        else k+=x-a[i];
    }
    cout<<k;
    
	return 0;
}

Measured memory_bytes: 5164
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i <= n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

using namespace std;

int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  while(A>0 && C>0){
    C -= B;
    if(C<=0){
      cout << "Yes" << endl;
      break;
    }
    A -= D;
    if(A<=0){
      cout << "No" << endl;
      break;
    }
  }
  return 0;
}


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

int main() {
    int A, B;
    std::cin >> A >> B;

    for (int i = 10; i <= 100000; ++i) {
        const int a = (int)(i * 8 / 100);
        const int b = (int)(i * 10 / 100);
       
        if (a == A && b == B) {
            std::printf("%d\n", i);
            return 0;
        } 
    }

    std::printf("-1\n");

    return 0;
}


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

int main(){

	ios::sync_with_stdio(false);
	int a, b, c;
	cin >> a >> b >> c;
	cout << min(c, b/a) << "\n";
	return 0;
}

Measured memory_bytes: 3604
n, m = map(int, input().split())
num = [-1 for _ in range(n)]
for i in range(m):
    si, ci = map(int, input().split())
    if num[si-1] == -1 or num[si-1]==ci:
        num[si-1] = ci
    else:
        print(-1)
        exit()

ans = ''
for i in range(n):
    if num[i] != -1:
        if i == 0 and num[i] == 0:
            if n == 1:
                print(0)
                exit()
            else:
                print(-1)
                exit()
        else:
            ans += str(num[i])
    else:
        if i == 0:
            if n == 1:
                ans += '0'
            else:
                ans += '1'
        else:
            ans += '0'

print(ans)

Measured memory_bytes: 3064
a,b=map(int, input().split()) 
ans = 0
if a >= b+1:
    ans = 2*a-1
elif b >= a+1:
    ans = 2*b-1
elif a == b:
    ans = a
    if a-1 < b:
        ans += b
    else:
        ans += a
print(ans)

Measured memory_bytes: 3060
gets
x = gets.split(" ").map(&:to_f)
y = gets.split(" ").map(&:to_f)
d = [x,y].transpose.map{|c| c.inject(:-).abs}
4.times do |i|
  puts ((i+1 == 4) ? d.max : d.map{|c| c**(i+1)}.inject(:+)**(1.0/(i+1)))
end

Measured memory_bytes: 8740
{-# LANGUAGE BangPatterns #-}

import qualified Data.Vector.Unboxed as U
-- import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import Data.List
import Control.Monad
import Control.Arrow
--import Data.Foldable
--import Data.Char
import qualified Data.IntMap.Strict as IM
--import qualified Data.IntSet as IS
-- import Data.Sequence as Sq

-- r :: Int -> IO (U.Vector Int)
-- r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine




main = do
    x <- readLn
    let smallerFactors = filter ((==0).(x`mod`)) [1..ceiling (sqrt $ fromIntegral x)]
    let biggerFactors = map (x `div`) smallerFactors
    -- print (smallerFactors,biggerFactors)
    printTup $ head $ map (\((b:_),d) -> (b+d,b)) $ filter (not.null.fst) $ map (\d -> (getExactB x d, d) ) (smallerFactors ++ biggerFactors)


printTup (a,b) = putStrLn $ show a ++ " " ++ show b



getExactB :: Int -> Int -> [Int]
getExactB x d = filter (\b ->  (b+d)^5 - b^5 == x ) (getBRange x d)

getBRange :: Int -> Int -> [Int]
getBRange x d = let m = round $ getB (fromIntegral x) (fromIntegral d)
    in [m-10..m+10]

getB x d = -(1/2)*sqrt(
                    ( (2 * (sqrt (d^6 + 4*d*x)) )   /    (sqrt 5 * d) )
                    -d^2
            )-(d/2)

Measured memory_bytes: 3828
def main():
    n = int(input())
    
    a_list = [n]

    for i in range(1000001):
        if a_list[i] % 2 == 0:
            tmp = a_list[i] // 2
        else:
            tmp = a_list[i] * 3 + 1
        
        if tmp in a_list:
            break
        a_list.append(tmp)

    print(len(a_list)+1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
#include <stdio.h>
int main(void)
{
	int h,w,n,i,j=0,x=0,t=1;
	scanf("%d %d",&h,&w);
	scanf("%d",&n);
	int a[10000],b[100][100],c[10000],y=w-1;
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		while(a[i]>0)
		{
			c[j++]=i;
			a[i]--;
		}
	}
	b[0][w-1]=1;
	while(t<j)
	{
		while(x+1<h&&!b[x+1][y]) 
		{
			b[++x][y]=c[t];
			t++;
		}
        while(y-1>=0&&!b[x][y-1]) 
		{
			b[x][--y]=c[t];
			t++;
		}
        while(x-1>=0&&!b[x-1][y]) 
		{
			b[--x][y]=c[t];
			t++;
		}
        while(y+1<w&&!b[x][y+1])  
		{
			b[x][++y] =c[t];
			t++;
		}
	}
	for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
	      printf("%d ",b[i][j]);
	    printf("\n");
	}
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
using namespace std;;
int main() {
	long long int n, a, money,x, i, s,p, j[70000];
	while (1) {
		cin >> n;
		if (n == 0)break;
		p = 0;
		money = 0;
		for (i = 0; i < n; i++) {
			cin >> a;
			p += a;
		}
		for (i = 0; i < n - 1; i++) {
			cin >> j[i];
		}
		sort(j, j + n - 1);
		for (i = 0; i <= n - 1; i++) {
			x = 0;
			x += p*(n - i);
			for (s = 0; s < i; s++) {
				x += j[n - 2 - s] * (n - i);
			}
			if (money < x) {
				money = x;
			}
			else {
				break;
			}
		}
		cout << money << endl;
	}
	return 0;
}

Measured memory_bytes: 3612
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;

vector<vector<int>> G;
bool bi;
vector<int> col;
void dfs(int u){
  for(int v:G[u]){
    if(col[v]==0){
      col[v]=-col[u];
      dfs(v);
    }
    if(col[u]==col[v])bi=false;
  }
}

int main(int argc, char const *argv[]) {
  long long n,m;cin>>n>>m;
  G=vector<vector<int>>(n);
  col=vector<int>(n);
  for(int i=0;i<m;++i){
    int u,v;cin>>u>>v;
    u--;v--;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  long long a=0,b=0,c=0;
  for(int i=0;i<n;++i){
    if(G[i].size()==0){
      c++;
      continue;
    }
    if(col[i]==0){
      col[i]=1;
      bi=true;
      dfs(i);
      if(bi)b++;
      else a++;
    }
  }
  cout<<(a+b)*(a+b)+b*b+2*c*n-c*c<<endl;
  return 0;
}


Measured memory_bytes: 9984
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD1 1000000007

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  int D = max(A, max(B, C));
  int ans = 3 * D - (A + B + C);
  if (ans % 2 != 0) {
    ans += 3;
  }

  ans /= 2; 

  cout << ans << endl;

}


Measured memory_bytes: 256
def resolve():
    X, Y, Z, K = list(map(int, input().split()))
    A = sorted(list(map(int, input().split())))
    B = sorted(list(map(int, input().split())))
    C = sorted(list(map(int, input().split())))

    AB = []
    for a in A:
        for b in B:
            AB.append(a+b)
    AB = sorted(AB, reverse=True)[:K]
    ABC = []
    for ab in AB:
        for c in C:
            ABC.append(ab+c)
    ABC = sorted(ABC, reverse=True)
    [print(ABC[i]) for i in range(K)]


if '__main__' == __name__:
    resolve()

Measured memory_bytes: 142076
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split())))

result = 0
for b in range(60):
  bs = int(((A >> b) & 1).sum())
  result = (result + bs * (N - bs) * (1 << b)) % 1000000007
print(result)


Measured memory_bytes: 48844
#!/usr/bin/env python3
#ABC63 C

n = int(input())
s = [int(input()) for _ in range(n)]
s.sort()
if sum(s) % 10 == 0:
    for i in s:
        if i % 10 != 0:
            print(sum(s) - i)
            break
    else:
        print(0)
else:
    print(sum(s))


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

int main(){
    string s, t;
    cin >> s >> t;
    int l=s.size();
    int a=0;
    for (int i=0; i<l; i++){
        if (s.at(i)!=t.at(i)){
            a++;
        }
        else{
        }
    }
    if (a==0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_bacm
#define mp mame_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    int n;
    cin >> n;
    string s = "No\n";
    while (n > 0){
        if (n % 10 == 7) s = "Yes\n";
        n /= 10;
    }
    cout << s;
}

int main(void){ 
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    //int t; cin >> t; while (t--)
        solve();
}


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

int main(){
    int n; cin>>n;
    vector<int> l(n);
    int sum=0,Max=0;
    for(int i=0; i<n; i++){
        cin>>l[i];
        Max = max(l[i],Max);
        sum += l[i];
    }

    if(2 * Max < sum) cout<<"Yes"<<endl;

    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define rep( i, s, t ) for( register int i = s; i <= t; ++ i )
#define re register
int gi() {
	char cc = getchar() ; int cn = 0, flus = 1 ;
	while( cc < '0' || cc > '9' ) {  if( cc == '-' ) flus = - flus ; cc = getchar() ; }
	while( cc >= '0' && cc <= '9' )  cn = cn * 10 + cc - '0', cc = getchar() ;
	return cn * flus ;
}
const int N = 1e6 + 5 ; 
int n, a[N], w[10], bk[10] ; 
char s[N] ; 
signed main()
{
	n = gi() ; int m = n - 1 ; 
	scanf("%s", s + 1 ) ;
	rep( i, 1, n ) a[i] = s[i] - '1' ; 
	rep( i, 1, n ) {
		bk[a[i]] = 1 ; 
		if( ( ( i - 1 ) & m ) != ( i - 1 ) ) continue ; 
		w[a[i]] ^= 1 ; 
	}
	if( w[1] ) {
		puts("1") ; exit(0) ; 
	}
	if( w[2] && ( !bk[1] ) ) {
		puts("2") ; exit(0) ;
	}
	puts("0") ; 
	return 0 ;
} 

Measured memory_bytes: 5120