akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 998244353;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {   
    string a, b, c; cin >> a >> b >> c;
    if(a.back()==b[0] && b.back()==c[0]){
        cout << "YES" << ln;
    }else cout << "NO" << ln;
}


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

using namespace std;

int main()
{
	char a[55][55] = { 0 };
	int x, y,i,j;
	cin >> x >> y;
	for (i = 0; i < x; i++)
		cin >> a[i];
	for (i = 0; i < x; i++)
		for (j = 0; j < y; j++)
		{
			if (a[i][j] == '.')
			{
				a[i][j] = 48;
				if (j>0 && a[i ][j - 1] == '#')a[i][j]++;
				if (a[i][j] == '#')a[i][j]++;
				if (j<y - 1 && a[i][j + 1] == '#')a[i][j]++;
				if (i > 0) 
				{ 
					if (j>0&&a[i - 1][j - 1] == '#')a[i][j]++;
					if (a[i - 1][j] == '#')a[i][j]++;
					if (j<y-1&&a[i - 1][j + 1] == '#')a[i][j]++;
				}
				if (i < x - 1) 
				{
					if (j>0 && a[i + 1][j - 1] == '#')a[i][j]++;
					if (a[i + 1][j] == '#')a[i][j]++;
					if (j<y - 1 && a[i + 1][j + 1] == '#')a[i][j]++;
				}
			}
		}
	for (i = 0; i < x; i++)
		cout << a[i] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
ll GCD(ll a,ll b) { return b ? GCD(b, a%b) : a; }
int main(){
  ll n;cin>>n;
  vector<ll> v(n);
  rep(i,n) cin>>v[i];
  vector<ll> left(n+1,0),right(n+1,0);
  rep(i,n) left[i+1]=GCD(left[i],v[i]);
  for(ll i=n-1;i>=0;i--) right[i]=GCD(right[i+1],v[i]);
  ll ans=0;
  rep(i,n) ans=max(ans,GCD(left[i],right[i+1]));
  cout<<ans<<endl;
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			String str = sc.next();
			int n = sc.nextInt();
			int cnt = 0;
			for(int i=0;i<n;i++) {
				String ring = sc.next();
				String Ring = ring+ring;
				for(int j=0;j<=ring.length()+1;j++) {
					if(Ring.indexOf(str,j) != -1) {
						cnt++;
						break;
					}
				}
			}
			System.out.println(cnt);
		}
	}
}


Measured memory_bytes: 26232
a, b, c, d = map(int, list(input()))
if a+b+c+d == 7: print(a,"+", b, "+", c, "+", d, "=7", sep="")
elif a+b+c-d == 7: print(a,"+", b, "+", c, "-", d, "=7", sep="")
elif a+b-c+d == 7: print(a,"+", b, "-", c, "+", d, "=7", sep="")
elif a-b+c+d == 7: print(a,"-", b, "+", c, "+", d, "=7", sep="")
elif a+b-c-d == 7: print(a,"+", b, "-", c, "-", d, "=7", sep="")
elif a-b-c+d == 7: print(a,"-", b, "-", c, "+", d, "=7", sep="")
elif a-b+c-d == 7: print(a,"-", b, "+", c, "-", d, "=7", sep="")
else: print(a,"-", b, "-", c, "-", d, "=7", sep="")

Measured memory_bytes: 3064
let () = Scanf.scanf "%d %d %d\n%d" @@ fun a b c k ->
  print_endline @@
  if
    List.fold_left (List.fold_left (List.fold_left ( || ))) false @@
    List.init (k + 1) @@ fun i ->
      List.init (k + 1 - i) @@ fun j ->
        List.init (k + 1 - i - j) @@ fun k ->
          let red = a lsl i in
          let green = b lsl j in
          let blue = c lsl k in
          green > red && blue > green
  then "Yes"
  else "No"

Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    //cout.precision(10);
    int n;
    cin >> n;
    cout << (n / 2) * ((n + 1) / 2) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<map>
#include<queue>
#include<cstring>
#include<stack>
#include<algorithm>
#include<vector>
using namespace std;

const int maxn = 2e5 + 5;
int father[maxn],other[maxn],pre[maxn],last[maxn],d[maxn];
int all = -1,ans = 0,n;

void build(int x,int y){
	pre[++all] = last[x];
	last[x] = all;
	other[all] = y;
}

void dfs(int x,int fa,int deep){
	int dt = last[x];
	while(dt != -1){
		int dr = other[dt];
		if(dr != fa){
			if(dr == n) ans = deep;
			father[dr] = x;
			dfs(dr,x,deep + 1);
			d[x] += d[dr] + 1;
		}
		dt = pre[dt];
	}
}

int main(){
	while(~scanf("%d",&n)){
		memset(last,-1,sizeof(last));
		for(int i = 1;i <= n - 1;i++){
			int x,y;
			scanf("%d %d",&x,&y);
			build(x,y);
			build(y,x);
		}	
		dfs(1,0,0);
		ans = ans / 2;
		int x = n;
		for(int  i = 1;i <= ans;i++) x = father[x];
		if(d[x] >= n - d[x] - 2) printf("Snuke\n");
		else printf("Fennec\n");
	}
}

Measured memory_bytes: 11136
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <cassert>
using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    int mx = (N-1)*(N-2)/2;
    if(K > mx){
        cout << -1 << endl;
        return 0;
    }
    vector<pair<int, int>> edges;
    for(int i=1; i<N; i++){
        edges.emplace_back(i, N);
    }
    int diff = mx - K;
    for(int i=1; i<N; i++){
        for(int j=i+1; j<N; j++){
            if(diff == 0) break;
            edges.emplace_back(i, j);
            diff--;
        }
    }
    cout << edges.size() << endl;
    for(auto xy : edges)
        cout << xy.first << " " << xy.second << endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll int64_t 
#define f(i,s,e) for(i=s;i<e;++i)
#define endl << "\n"
#define sp << " "
#define INF INFINITY
#define mset(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI acos(-1) 
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define eb(a) emplace_back(a)
#define print(x) for(auto it:x) cout<<it<<' '; cout<<"\n";

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace std;

int main()
{
	FAST_IO ;
	ll i,j,k,n;
	cin >> n;
	vector <ll> arr(n) ;
	f(i,0,n)
		cin >> arr[i] ;
	ll max1 = arr[0] ;
	ll ans = 0;
	f(i,0,n)
	{
		if(arr[i]>=max1)
			max1 = arr[i] ;
		else
			ans += max1-arr[i] ;
	}
	cout << ans endl ;
	return 0;
}

/*
If u haven't come up with an approach yet ,skip this one
  Try this when feeling stuck -
  1. Int overflow, array bounds
  2. Special cases (n=1?)
  3. Prove your approach to yourself(mathematical induction,counter-intuitive or stronger test cases)
  4. Calm down and don't look at standings and stop thinking about rating and think about the question
  5. Just do it! 
*/ 

//Benq's advice - 
/* 
	And following advices are must for me -
	* do something instead of nothing and stay organized
	* WRITE STUFF DOWN 
*/

//#define _GLIBCXX_DEBUG 
// It will convert WA verdict to runtime error if that error is caused due to out of bound excess , declare it at the top
//#pragma GCC optimize "trapv" 
// It will convert WA to runtime error if WA was caused due to int overflow error,declare it anywhere

Measured memory_bytes: 4764
def func():
    s = int(input())

    a = [s]
    found = False
    i = 1
    ans = -1
    while not found:
        if a[i - 1] % 2 == 0:
            a.append(a[i - 1] / 2)
        else:
            a.append(3 * a[i-1]+1)

        for j in range(len(a) - 1):
            if a[j] == a[-1]:
                found = True
                ans = i + 1
                break

        i += 1

    print(ans)


if __name__ == '__main__':
    func()


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

using namespace std;


int main() {
  int64_t n;
  cin >> n;
  int64_t ans = 0;
  for(int64_t i = 2; i * i < n; i++) {
    int64_t a = 0;
    while(n % i == 0) {
      a++;
      n /= i;
    }
    for(int64_t j = 1; j <= a; j++) {
      a -= j;
      ans++;
    }
  }
  if(n != 1) ans++;
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3548
#include<iostream>
#include<string>
#include <cmath>
#include <algorithm>
#define MOD 1e9+7
using namespace std;
typedef long long ll;

int main(){

int n;
char c[100];

cin >> n;

for(int i = 0; i <n; i++) cin >> c[i];

int x = 0,max = 0;

for(int i = 0; i <n; i++) {
if(c[i] == 'I') x++;
else x--;
if(max < x) max = x;
}

cout << max << endl;

return 0;
}

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

using namespace std;

typedef long long ll;

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

	ll a, b, n;
	cin >> a >> b >> n;

	ll y = min(b - 1, n);
	ll a0 = a / b;
	ll a1 = a % b;
	cout << a0 * y + a1 * y / b << endl;
}


Measured memory_bytes: 3620
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int N = in.i();
        int[] A = in.ii(N);

        int ans = 0;
        for (int i = 0; i < N; ) {
            int j = i;
            int x = Integer.MAX_VALUE;
            while (j < N && A[j] <= x) {
                x = A[j++];
            }

            int y = 0;
            int k = i;
            while (k < N && y <= A[k]) {
                y = A[k++];
            }

            ans++;
            i = Math.max(j, k);
        }
        
        out.println(ans);
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (isDelimiter(next()));
        back();
    }

    char[] s(int N) {
        char[] cbuf = new char[N];
        read(cbuf, 0, N);
        return cbuf;
    }

    public int read(char[] cbuf, int off, int len) {
        skip();
        int i;
        for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        }
        return i;
    }

    boolean isDelimiter(char c) {
        return c == ' ' || c == '\n' || c == '\r';
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}


Measured memory_bytes: 36072
#include<stdio.h>
#define MAX 45

int F[45];

int fib(int n)
{
  if (n == 0 || n == 1) return F[n] = 1;
  if(F[n] != -1) return F[n]; //F[n]が計算済みならそれを返す
  return F[n] = fib(n - 2) + fib(n - 1);
}

int main()
{
  int i,x;
  for(i=0;i<MAX;i++){
    F[i] = -1;
  }

  scanf("%d",&x);
  printf("%d\n",fib(x));

  return 0;
}
    
 
  



Measured memory_bytes: 2100
pub struct ProconReader<R: std::io::Read> {
    reader: R,
}

impl<R: std::io::Read> ProconReader<R> {
    pub fn new(reader: R) -> Self {
        Self { reader }
    }
    pub fn get<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&byte| byte == b' ' || byte == b'\n' || byte == b'\r')
            .take_while(|&byte| byte != b' ' && byte != b'\n' && byte != b'\r')
            .collect::<Vec<_>>();
        std::str::from_utf8(&buf)
            .unwrap()
            .parse()
            .ok()
            .expect("Parse Error.")
    }
}

mod rolling_hash {
    const MASK30: u64 = (1 << 30) - 1;
    const MASK31: u64 = (1 << 31) - 1;
    const MOD: u64 = (1 << 61) - 1;
    const MASK61: u64 = (1 << 61) - 1;
    const POSITIVIZER: u64 = MOD * 4;
    const BASE: u64 = 1_000_000_000 + 9;
    pub struct RollingHash {
        h: Vec<u64>,
        p: Vec<u64>,
    }
    impl RollingHash {
        pub fn new(s: &[u64]) -> Self {
            let n = s.len();
            let mut h = vec![0; n + 1];
            let mut p = vec![0; n + 1];
            p[0] = 1;
            for i in 0..n {
                h[i + 1] = calc_mod(mul(h[i], BASE) + s[i]);
                p[i + 1] = calc_mod(mul(p[i], BASE));
            }
            Self { h, p }
        }
        pub fn get(&self, range: std::ops::Range<usize>) -> u64 {
            let l = range.start;
            let r = range.end;
            calc_mod(self.h[r] + POSITIVIZER - mul(self.h[l], self.p[r - l]))
        }
    }
    fn mul(a: u64, b: u64) -> u64 {
        let au = a >> 31;
        let ad = a & MASK31;
        let bu = b >> 31;
        let bd = b & MASK31;
        let mid = ad * bu + au * bd;
        let midu = mid >> 30;
        let midd = mid & MASK30;
        au * bu * 2 + midu + (midd << 31) + ad * bd
    }
    fn calc_mod(x: u64) -> u64 {
        let xu = x >> 61;
        let xd = x & MASK61;
        let mut res = xu + xd;
        if res >= MOD {
            res -= MOD;
        }
        res
    }
}

fn main() {
    let stdin = std::io::stdin();
    let mut rd = ProconReader::new(stdin.lock());

    use rolling_hash::RollingHash;

    let n: usize = rd.get();
    let s: String = rd.get();
    let t = s.chars().map(|c| c as u64).collect::<Vec<_>>();
    let rh = RollingHash::new(&t);
    let mut ans = 0;
    for i in 0..n {
        for j in (i + 1)..n {
            let mut ok = 0;
            let mut ng = std::cmp::min(j - i, n - j) + 1;
            while ng - ok > 1 {
                let m = (ng + ok) / 2;
                if rh.get(i..(i + m)) == rh.get(j..(j + m)) {
                    ok = m;
                } else {
                    ng = m;
                }
            }
            ans = std::cmp::max(ans, ok);
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2272
/*  -*- coding: utf-8 -*-
 *
 * b.cc: D: Remainder Reminder
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

typedef long long ll;

/* global variables */

/* subroutines */

/* main */

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

  if (k == 0) {
    printf("%lld\n", (ll)n * n);
    return 0;
  }
  
  ll sum = 0;
  for (int b = k + 1; b <= n; b++) {
    int c = n / b, d = n % b;
    sum += (ll)c * (b - k) + (d >= k ? (d + 1 - k) : 0);
  }

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


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

int main(void){
	string str;
	while(cin >> str){
		string str2;
		for(int i=0;i<str.size();i++){
			if(str[i]=='@'){
				int a=str[i+1]-'0';
				for(int j=0;j<a;j++){
					str2+=str[i+2];
				}
				i+=2;
			}
			else str2+=str[i];
		}
		cout << str2 << endl;
	}
    return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 0
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;

int n,ans;
int m,q;
int a[51],b[51],c[51],d[51];
int A[11],Af[11];
vector<int> v[11];
void dfs(int num,int i){
	A[i]=num;
	if(i==n-1){
		int sum=0;
		rep(j,q){
			if(A[b[j]]-A[a[j]]==c[j])sum+=d[j];
		}
		ans=max(ans,sum);
		return ;
	}
	rep(j,v[num].size()){
		dfs(v[num][j],i+1);
	}
}
signed main(){
	cin>>n>>m>>q;
	rep(i,q){
		cin>>a[i]>>b[i]>>c[i]>>d[i];
		a[i]--;b[i]--;
	}
	for(int i=0;i<m;i++){
		for(int j=i;j<m;j++){
			v[i].push_back(j);
		}
	}
	rep(i,m){
		dfs(i,0);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3644
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <limits>

using ll = long long int;
using ul = unsigned long long int;

namespace lamlib
{
	// EPSITON
	constexpr double epsilon = std::numeric_limits<double>::epsilon();
	// Absolute
	template<class T> inline T abs(const T &a){ return (a>0) ? a : -a; }
	// Digit
	ul inline digit(const ul &num){ return static_cast<ul>(std::log10(num+epsilon))+1; }
	// GCD: a > b
	ul gcd(ul a,ul b) { return (!b) ? a : gcd(b,a%b); }

	/* string */
	inline ul same_char_count(const std::string s,const char &ch){ return std::count(std::cbegin(s),std::cend(s),ch); }
}

int main(int argc,char *argv[])
{
	constexpr ul m = 2019;
	auto expr = [&](const ul &l,const ul&r){ return ((l%m)*(r%m))%m; };

	ul l,r;
	std::cin >> l >> r;

	ul ans = 0;
	if(r - l < 2019)
	{
		ans = 2018;
		for(ul a = l;a < r;++a)
			for(ul b = r;b > l;--b)
			{
				auto tmp = expr(a,b);
				if (ans > tmp) ans = tmp;
			}
	}
	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define INF 1073741824
#define ll long long
#define PI (2*acos(0.0))
#define p1(n) printf("showing %d\n",n)
#define p2(m,n) printf("showing %d %d\n",m,n)
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define x first
#define y second
#define on(val,pos) val|(1<<pos)
#define off(val,pos) val&(~(1<<pos))
#define check(val,pos) (val&(1<<pos))
#define all(n) n.begin(),n.end()
//first four adjacent,second four corner
//int row[8]={0,-1,0,1,1,-1,-1,1};
//int col[8]={-1,0,1,0,-1,-1,1,1};
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int main(){
    int i,j,n,m,val,t=0,test;
    //freopen("000input.txt","r",stdin);
   long double a,b,c;
  cin>>a>>b;
  ll k=floor(a*b);
  cout<<k<<endl;
    //free();   //if pointer array
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    int s[n];
    int count_multiple_of_10 = 0;
    rep(i,n) {
        cin >> s[i];
        if (s[i] % 10 == 0) count_multiple_of_10++; 
    }
    if (count_multiple_of_10 == n) {
        cout << 0 << endl;
        return 0;
    }
    sort(s, s+n);
    int sum_s = accumulate(s, s+n, 0);
    int i = 0;
    while (sum_s % 10 == 0) {
        if (s[i] % 10 != 0) {
            sum_s -= s[i];
        }
        i++;
    }
    cout << sum_s << endl;
}

Measured memory_bytes: 256
//
// ~oisín~ C++ Template
//

#include                <bits/stdc++.h>
#define MX_N            5001
#define mp              make_pair
#define mod7            1000000007
#define modpi           314159
#define PI              3.141592653589793238
#define pb              push_back
#define FastIO          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define All(a)          a.begin(),a.end()
#define fi              first
#define se              second
#define ll              long long int
#define ull             unsigned long long int

int kx[8]  =            {+2, +2, -2, -2, +1, +1, -1, -1};
int ky[8]  =            {+1, -1, +1, -1, +2, -2, +2, -2};
int d9x[9] =            {+1, +1, +1, +0, +0, +0, -1, -1, -1};
int d9y[9] =            {+1, +0, -1, +1, +0, -1, +1, +0, -1};
int dx4[4] =            {+0, +0, +1, -1};
int dy4[4] =            {+1, -1, +0, +0};

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

ll lcm(ull a, ull b){
    return a*(b/gcd(a,b));
}

const long long INF = 1e18;

using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    cout << a*b << endl;
}


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

//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = (LL)INF * INF;

int main()
{
	//ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	LL n, a, b;
	cin >> n >> a >> b;
	if((b - a) % 2 == 0)
		cout << (b - a) / 2 << "\n";
	else
		cout << min(a, n - b + 1) + (b - a - 1) / 2 << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <cmath>

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

int main(){
    int n;
    cin >> n;
    vector<int> a(200010);
    rep(i, n) cin >> a[i];
    vector<int> b = a;
    sort(b.begin(), b.end(), greater<int>());
    rep(i, n) {
        if (a[i] == b[0]) cout << b[1] << endl;
        else cout << b[0] << endl;;
    }
}

Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>

#include <stdio.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, k, n) for (int i = (k); i < (n); i++)
#define rrep(i, k, n) for (int i = (k); i >= (n); i++)
#define pb push_back
#define vec vector
#define ref(a) &(a)

typedef long long ll;

using namespace std;

int n;
string s, t;

string solve() {
  string res = "";
  rep(i, n) {
    res.pb(s[i]);
    res.pb(t[i]);
  }
  return res;
}

int main() {
  cin >> n;
  cin >> s >> t;
  cout << solve() << endl;
}

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

using ll = long long;

int main() {
	ll h, n;
	cin >> h >> n;

	ll a;
	ll sum = 0;
	while (n > 0) {
		cin >> a;
		sum += a;
		--n;
	}

	cout << (sum >= h ? "Yes\n" : "No\n");
	return 0;
}


Measured memory_bytes: 256
N = int(input())
arr = list(map(int,input().split()))
def S1(a,b):
    c,total,ans = 0,0,0
    for t in arr:
        c += 1
        if c % 2 == a:
            if total+t <= 0:
                ans += abs(total+t)+1
                total = 1
                continue
        elif c % 2 == b:
            if total+t >= 0:
                ans += abs(total+t)+1
                total = -1
                continue
        total += t
    return ans
print(min(S1(1,0),S1(0,1)))

Measured memory_bytes: 14468
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
int main()
{
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    double r = a*a+b*b;
    double angle = fabs((60*h-11*m)/2);
    angle = (M_PI/180.0)*angle;
    double ans = sqrt(r-2*a*b*cos(angle));
    printf("%.10f",ans);
}   


Measured memory_bytes: 4292
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = int64_t;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    vector<vector<int>> G(n);
    for (int i = 0; i < n-1; ++i) {
        int a, b;
        cin >> a >> b;
        G[a-1].emplace_back(b-1);
        G[b-1].emplace_back(a-1);
    }
    deque<int> Q;
    vector<int> num(n);
    {
        stack<int> s;
        int cnt = 0;
        vector<int> visited(n, 0);
        s.emplace(0);
        while(!s.empty()){
            int a = s.top(); s.pop();
            visited[a]++;
            num[a] = cnt++;
            Q.emplace_front(a);
            for (auto &&i : G[a]) {
                if(!visited[i]) s.emplace(i);
            }
        }
    }
    vector<int> dp(n, 0);
    while(!Q.empty()){
        int i = Q.front(); Q.pop_front();
        for (auto &&j : G[i]) {
            if(num[i] < num[j]){
                dp[i] ^= dp[j]+1;
            }
        }
    }
    puts(dp[0] ? "Alice" : "Bob");
    return 0;
}


Measured memory_bytes: 7040
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
int const M=1e6+10,M2=1e6+10,M3=1e3+10,inf=1e9+10,mod=1e9+7;
int d[M][20],e[M][20],now=0;
void fans(int mask,int j)
{
	int cnt=0;
	for(int k=0;k<10;k++)
	{
		if(mask & (1<<k) && (d[j][k]))
		{
			cnt++;
		}
	}
	now+=e[j][cnt];
}
main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<10;j++)
			cin>>d[i][j];
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=10;j++)
			cin>>e[i][j];
	}
	int ans=-inf;
	for(int i=1;i<=1023;i++)
	{
		now=0;
		for(int j=1;j<=n;j++)
		{
			fans(i,j);
		}
		ans=max(ans,now);
	}
	cout<<ans;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9 + 7;

int main()
{
  string s, t;
  cin >> s >> t;
  for (int i = s.size() - t.size(); i >= 0; --i)
  {
    bool check = true;
    for (int j = 0; j < t.size(); ++j)
    {
      if (s[i + j] != t[j] && s[i + j] != '?')
        check = false;
    }
    if (check)
    {
      for (int j = 0; j < t.size(); ++j)
        s[i + j] = t[j];
      for (int j = 0; j < s.size(); ++j)
        if (s[j] == '?')
          s[j] = 'a';
      cout << s << endl;
      return 0;
    }
  }
  cout << "UNRESTORABLE" << endl;

  return 0;
}


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

int main ()
{
  int n,k;
  cin>>n>>k;
  int a;
  cin>>a;
  int max1  =a;
  for (int i =1 ; i<n;i++) {
    int b;
    cin>>b;
    a=__gcd(a,b);
    max1=max(max1,b);
  }
  if (k%a == 0 && k<= max1) {
    cout<<"POSSIBLE"<<endl;
  }
  else {
    cout<<"IMPOSSIBLE"<<endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	long x, a, b;
	long aa, bb;
	long i, j, k;

	cin >> x;
	for (a = -120; a <= 120; a++) {
		for (b = -120; b <= 120; b++) {
			aa = pow(a, 5);
			bb = pow(b, 5);
			if (aa - bb == x) {
				cout << a << " " << b << endl;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 4096
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scanner = new Scanner(System.in);

//		int N = scanner.nextInt();
//
//		int K = scanner.nextInt();

		long N = scanner.nextLong();

		long ans =0;
		for(long index=0; index < N; index++) {
			ans+=index+1;
		}

		log(ans-N);

//		int[] scannerArray = new int[N];
//
//		for (int index = 0; index < N; index++) {
//			scannerArray[index] = scanner.nextInt();
//		}
//
//		int tmp = countSwapBabbleSort(scannerArray);
//
//		log((
//				(BigInteger.valueOf((long)tmp)
//				.multiply(BigInteger.valueOf((long)K)
//						))
//				.add((
//						BigInteger.valueOf((long)tmp)
//						.multiply(
//								BigInteger.valueOf((long)K)
//								.multiply(
//										BigInteger.valueOf((long)K)
//										.subtract(BigInteger.ONE)
//										)
//								.divide(BigInteger.valueOf((long)2)
//										)
//								)
//						)))
//				.remainder(
//						BigInteger.valueOf((long)1000000007)
//						)
//				.toString());
	}


	/**
	 * バブルソートの交換数を算出
	 * ※転倒数
	 * @param array
	 * @return
	 */
	private static int countSwapBabbleSort(int[] array) {
		int ans = 0;
		int[] binary = new int[array.length + 1];

		for (int index = 0; index < array.length; index++) {
			ans = ans + (index - sum(binary, array[index]));
			add(binary, array[index], 1);
		}
		return ans;
	}

    //add value at idx on bit O(logN)
	private static void add(int[] bit,int idx,int value) {
        for(int i=idx;i<bit.length;i=i+(i&-i)) {
        	bit[i] += value;
        }
    }

    //return sum [1,idx] O(logN)
	private static int sum(int[] bit,int idx) {
        int ret = 0;
        for(int i=idx;i>0;i-=(i&-i)) {
        	ret += bit[i];
        }
        return ret;
    }

	private static void log(String str) {
		System.out.println(str);
	}

	private static void log(int str) {
		System.out.println(str);
	}

	private static void log(long str) {
		System.out.println(str);
	}

	private static void log(double str) {
		System.out.println(str);
	}

}



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

int main(){

  string s;
  cin >> s;
  int n=s.size();
  for(int i=0; i<n; i++){
    cout << "x";
  }
  cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <utility>
#include <vector>
#include <algorithm>
#include <iostream>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
using namespace std;

#define y0 y910831
#define y1 y923456
#define j0 j771912
#define j1 j442401
#define next next18181
#define prev prev18181

using ll = long long;
using ul = unsigned long;
#define INF 1LL<<60
#define PRIME 1000000007
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, 1, -1};
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,k;
	cin >> n >> k;
	if((1+n)/2>=k){
		cout << "YES";
	}else{
		cout << "NO";
	}

	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
S=sum(A)

for i in range(N):
  if B[i] <= A[i]:
    A[i] -= B[i]
  elif A[i] < B[i] <= A[i] + A[i+1]:
    B[i] -= A[i]
    A[i] = 0
    A[i+1] -= B[i]
  else:
    A[i] = 0
    A[i+1] = 0

S_=sum(A)

print(S-S_)

Measured memory_bytes: 24120
#include <bits/stdc++.h>
#define IO                       \
    ios::sync_with_stdio(false); \
    cin.tie(0);                  \
    cout.tie(0);
#define mem(a, x) memset(a, x, sizeof(a))
#define per(x, a, b) for (int x = a; x <= b; x++)
#define rep(x, a, b) for (int x = a; x >= b; x--)

using namespace std;
typedef long long LL;
typedef pair<int, int> P;
const int maxn = 1e5 + 10;
const int mod = 1e9 + 7;
const double eps = 1e-8;

int n;
char str[maxn];
int ch[maxn];
void solve() {
    mem(ch, 0);
    LL ans = 1;
    for (int i = 0; i < n; i++) {
        ch[str[i] - 'a']++;
    }
    for (int i = 0; i < 26; i++) {
        ans *= ch[i] + 1;
        ans %= mod;
    }
    ans--;
    ans = (ans % mod + mod) % mod;
    cout << ans << endl;
}

int main() {
#ifdef LOCAL_IM0QIANQIAN
    freopen("test.in", "r", stdin);
//    freopen("test.out", "w", stdout);
#else
    IO;
#endif // LOCAL_IM0QIANQIAN

    while (cin >> n) {
        cin >> str;
        solve();
    }
    return 0;
}

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

//解説AC

int main(){
    string s;
    long long k;
    cin >> s >> k;
    int n = s.size();
    long long x = 0;
    for(int i = 0; i < n-1; i++){
        if(s[i] == s[i+1]){
            x++;
            i++;
        }
    }
    long long ans = x * k;

    if( count(s.begin(), s.end(), s[0]) == n){
        if(n % 2 == 1){
            ans = n * k / 2;
        }
    }else if(s[0] == s[n-1]){
        int i = 1;
        long long m = 2;
        while(s[i] == s[0]){
            m++;
            i++;
        }
        i = n -2;
        while(s[i] == s[0]){
            m++;
            i--;
        }
        if(m % 2 == 0){
            ans += k-1;
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm(a, b) (a)/__gcd((a),(b))*(b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

vector<int> Div(int n) {
    vector<int> ret;
    for(int i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);

            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int n, a, b;
    cin >> n >> a >> b;

    int s = 0;
    for(int i = 1; i <= n; ++i) {
        int ss = 0;
        int t = i;
        while(t > 0) {
            ss += t % 10;
            t /= 10;

        }
        if(a <= ss && ss <= b) s += i;

    }
    cout << s << endl;
    return 0;
}



Measured memory_bytes: 256
import math
N = int(input())
t= 1
a= 1

def t_small(t,a,t1,a1):
    gain = -(-t//t1)
    t = gain*t1
    a_tmp=gain*a1
    if a_tmp<a:
        gain_a = -(-a//a_tmp)
        t *= gain_a
        a = a_tmp*gain_a
    else:
        a = a_tmp
    return t,a,t+a

def a_small(t,a,t1,a1):
    gain = -(-a//a1)
    a = gain*a1
    t_tmp=gain*t1
    if t_tmp<t:
        gain_t = -(-t//t_tmp)
        a *= gain_t
        t = t_tmp*gain_t
    else:
        t = t_tmp
    return t,a,t+a

ans = 0
for _ in range(N):
    t1,a1 = map(int,input().split())
    tt1,aa1,sta1 = t_small(t,a,t1,a1)
    tt2,aa2,sta2 = a_small(t,a,t1,a1)
    if sta1<=sta2:
        t=tt1;a=aa1;ans = sta1
    else:
        t=tt2;a=aa2;ans=sta2
print(ans)


Measured memory_bytes: 9112
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin>>n;
	vector<ll>arr(n);
	for(ll i=0;i<n;i++)
		cin>>arr[i];
	ll c=0;
	for(ll i=0;i<n;i++)
	{
		if(arr[i]!=(i+1))
			c++;
	}
	if(c==0 || c==2)
		cout<<"YES";
	else cout<<"NO";
    return 0;
}


//252908XL

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
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;}

int main(){

    int a,b,c;
    cin>>a>>b>>c;
    if(a%2==1 || b%2==1 || c%2==1) {
        cout<<0<<endl;
        return 0;
    }

    if(a==b && b==c) {
        cout<<-1<<endl;
        return 0;
    }
    int p,q,r;
    int ans = 0;
    while(a%2!=1 && b%2!=1 && c%2!=1){
        ans++;
        p = a/2 + b/2;
        q = b/2 + c/2;
        r = c/2 + a/2;
        a=q;b=r;c=p;
    }
    cout<<ans<<endl;
}

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

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

  FOR(i, 1, 1300) {
    if ((i * 8)/100 == A && (i * 10)/100 == B){
      cout << i << endl;
      return 0;
    }

  }
  cout << -1 << endl;
}


Measured memory_bytes: 256
// ※※※ 解答不能 ※※※
// lpuwfob氏.
// https://atcoder.jp/contests/ddcc2020-qual/submissions/8582087
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const LL MOD = 1e9 + 7;

// Fermat's little theorem から, 大きな冪乗の計算を行う.
// @param a: べき乗したい正整数.
// @param b: 指数.
// @return:  べき乗した計算結果(mod版).
LL binpow(LL a, LL b){
    LL t = 1;
    while(b){
        if(b & 1) t = (t * a) % MOD;
        a *= a;
        a %= MOD;
        b >>= 1;
    }
    return t % MOD;
}

int main(){
    LL n, m, t;
    scanf("%d %d %d", &n, &m, &t);
    LL r = __gcd(n, t);
    n /= __gcd(n, t);
    r *= __gcd(m, t);
    m /= __gcd(m, t);
    printf("%lld\n", binpow((binpow(2, n) + binpow(2, m) + binpow(2, __gcd(n, m)) - 3 + MOD) % MOD, r));
    return 0;
}

Measured memory_bytes: 256
public class Main{
  static int top;
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int i, j, h, w, a, x, y;
    char[][] f;
    int[] nowx, nowy;
    int[][] count;
    String s;

    for(;;){
      h = sc.nextInt(); w = sc.nextInt();
      if(h == 0 && w == 0)break;
      f = new char[h][w]; count = new int[h][w];
      nowx = new int[h * w]; nowy = new int[h * w]; top = 0; a = 0;

      for(i = 0;i < h;i++){
        s = sc.next();
        for(j = 0;j < w;j++){
          f[i][j] = s.charAt(j); count[i][j] = 0;
        }
      }

      for(i = 0;i < h;i++)for(j = 0;j < w;j++){
        if(count[i][j] == 0){
          count[i][j]++; a++;
          pushxy(nowx, nowy, i, j);
          for(;top > 0;){
            x = popx(nowx); y = popy(nowy);
            if(x != 0 && f[x][y] == f[x - 1][y] && count[x - 1][y] == 0){
              count[x - 1][y]++;
              pushxy(nowx, nowy, x - 1, y);
            }
            if(x != h - 1 && f[x][y] == f[x + 1][y] && count[x + 1][y] == 0){
              count[x + 1][y]++;
              pushxy(nowx, nowy, x + 1, y);
            }
            if(y != 0 && f[x][y] == f[x][y - 1] && count[x][y - 1] == 0){
              count[x][y - 1]++;
              pushxy(nowx, nowy, x, y - 1);
            }
            if(y != w - 1 && f[x][y] == f[x][y + 1] && count[x][y + 1] == 0){
              count[x][y + 1]++;
              pushxy(nowx, nowy, x, y + 1);
            }
          }
        }
      }

      out.println(a);
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
  private static int popx(int[] nowx){
    return nowx[--top];
  }
  private static int popy(int[] nowy){
    return nowy[top];
  }
  private static void pushxy(int[] nowx, int[] nowy, int x, int y){
    nowx[top] = x; nowy[top++] = y;
    return;
  }
}

Measured memory_bytes: 22324
m = [/11[02]{7}11/,/1[02]{8}1[02]{8}1[02]{8}1/,/1111/,/1[02]{7}11[02]{7}1/,/11[02]{8}11/,/1[02]{8}11[02]{8}1/,/11[02]{6}11/]
d = ["A","B","C","D","E","F","G"]
loop do
  s=""
  8.times{
    s += gets.chomp+'2'
  }
  7.times{|i|
    if s.index(m[i])
      puts d[i]
      break
    end
  }
  exit(0) if gets == nil
end

Measured memory_bytes: 6092
def main():
    from sys import setrecursionlimit, stdin, stderr
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor
    from itertools import accumulate, combinations, combinations_with_replacement, product
    setrecursionlimit(10**6)
    dbg = (lambda *something: stderr.write("\033[92m{}\033[0m".format(str(something)+'\n'))) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**12

    N = II()
    positions = deque()
    for i in range(N):
        positions.append(LMIIS())
    
    #縦、横の最短距離
    v = []
    h = []
    for i in range(2**N):
        v.append([INF]*N)
        h.append([INF]*N)
    for i in range(2**N):
        v_lines = deque([0])
        h_lines = deque([0])
        for j in range(N):
            if 2 ** j & i:
                v_lines.append(positions[j][0])
                h_lines.append(positions[j][1])
        for j,(x,y,p) in enumerate(positions):
            min_x = INF
            min_y = INF
            for x_c in v_lines:
                min_x = min(min_x, abs(x_c - x)*p)
            for y_c in h_lines:
                min_y = min(min_y, abs(y_c - y)*p)
            v[i][j] = min_x
            h[i][j] = min_y

    ans = [INF]*(N+1)
    #for pattern in product(range(3),repeat=N):
    n_bit_mask = (1<<N)-1
    for pattern in range(2**N):
        
        cities = [i for i in range(N) if 2**i&pattern==0]
        key = N - len(cities)
        

        pattern_v = pattern
        pattern_h = 0
        
        while True:
            sum_diff = 0
            for i in cities:
                sum_diff += min(v[pattern_v][i],h[pattern_h][i])
            ans[key] = min(ans[key], sum_diff)
            if pattern_v == 0:
                break
            pattern_v = (pattern_v-1)&pattern
            pattern_h = pattern - pattern_v
    print('\n'.join(map(str,ans)))





            



    

    



    
main()

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

int main()
{
    int a,b,x;
    cin>>a>>b>>x;
    double aa=(double)a;
    double bb=(double)b;
    double s=(double)x/aa;    
    if (s<aa*bb/2){
        printf("%.10f",atan(bb*bb/(2.*s))*180/M_PI);
    }else{
        printf("%.10f",atan((aa*bb-s)/(aa*aa/2.))*180/M_PI);
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int maxn=1e6 + 10;
int p[maxn],inp[maxn],f[maxn],top;
void init(){
	for(int i=2;i<maxn;i++){
		if(!inp[i]){
			p[top++]=i;
		}
		for(int j=0;j<top && i*p[j]<maxn;j++){
			inp[i*p[j]]=1;
			if(!(i%p[j]))
				break;
		}
		f[i]=f[i-1]+1-inp[i];
	}
}
int main(){
	init();
	int n;
	while(cin>>n){
		cout<<f[n]<<endl;
	}
	return 0;
}

Measured memory_bytes: 9348
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)

//-----------------------------------------------

//------------------------------------------------
int main(){
  int n;
  cin>>n;
    cout<<n*n*n<<endl;
}


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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());

			decimal sum = 0;

			decimal[] arr = Console.ReadLine().Trim().Split(' ').Select(tmp => decimal.Parse(tmp)).ToArray<decimal>();

			for (int i = 0; i < n; i++)
			{
				sum += 1 / arr[i];
			}

			Console.WriteLine(1 / sum);
		}
	}
}


Measured memory_bytes: 13396
import heapq
k = int(input())
l = [1,2,3,4,5,6,7,8,9]
heapq.heapify(l)
count = 0
now = 0
while count < k:
    #print(count,l)
    a = str(heapq.heappop(l))
    count += 1
    now = int(a)
    al = list(a)
    if al[-1] == "0":
        heapq.heappush(l,int(a+"0"))
        heapq.heappush(l,int(a+"1"))
    elif al[-1] == "9":
        heapq.heappush(l,int(a+"8"))
        heapq.heappush(l,int(a+"9"))
    else:
        heapq.heappush(l,int(a+str(int(al[-1])-1)))
        heapq.heappush(l,int(a+str(int(al[-1]))))
        heapq.heappush(l,int(a+str(int(al[-1])+1)))
print(now)

Measured memory_bytes: 10736
import java.util.*;

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

        Scanner sc = new Scanner(System.in);
        while(true){
            int a = sc.nextInt();
            int b = sc.nextInt();
            if(a==0&&b==0) break;
            for(int i = 0; i<a;i++){
                for(int j = 0;j<b;j++){
                    System.out.print("#");
                }   
                System.out.println();
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 33272
#include <iostream>

using namespace std;

int main()
{
    int m;
    long long k, p = 1ll;

    cin >> m >> k;

    for (int i = 0;i < m;i++) p *= 2ll;

    if (k >= p) cout << -1 << endl;
    else if (m == 1)
    {
        if (k == 0)
        {
            cout << "0 0 1 1" << endl;
        }else
        {
            cout << -1 << endl;
        }
    }else
    {
        for (long long i = 0ll;i < p;i++)
        {
            if (i != k) cout << i << " ";
        }
        cout << k << " ";
        for (long long i = p-1;i >= 0ll;i--)
        {
            if (i != k) cout << i << " ";
        }
        cout << k << endl;
    }
}

Measured memory_bytes: 1792
use std::io;

fn main() {
    let number = input_number();
    let n = number[0];
    let m = number[1];

    let mut a: Vec<Vec<i64>> = vec![];
    for _ in 0..n {
        a.push(input_number());
    }

    let mut c: Vec<i64> = vec![];
    for _ in 0..m {
        let number = input_number();
        c.push(number[0]);
    }

    for index in 0..n {
       let mut sum = 0i64;
       for index2 in 0..m {
           sum += a[index as usize][index2 as usize] * c[index2 as usize];
       }
       println!("{}", sum);
    }
}

#[allow(dead_code)]
fn input_number() -> Vec<i64> {
    let mut input = String::new();
    io::stdin().read_line(&mut input) .expect("Failed to read line");
    let vec: Vec<i64> = input
        .split_whitespace()
        .map(|x| x.parse().unwrap_or(0))
        .collect();
    vec
}

#[allow(dead_code)]
fn input() -> (char, usize) {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    let mut iter = s.trim().split_whitespace();
    let c:char = iter.next().unwrap().chars().nth(0).unwrap();
    let n:usize = iter.next().unwrap().parse().unwrap();
    (c, n)
}



Measured memory_bytes: 5056
#![allow(non_snake_case)]
#![allow(unused_variables)]

fn main() {
    let x: i64 = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };

    let ans = if x % 11 == 0 {
        2 * (x / 11)
    } else if x % 11 <= 6 {
        2 * (x / 11) + 1
    } else {
        2 * (x / 11) + 2
    };

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b){if(a < b){ a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b){if(a > b){ a = b; return 1;} return 0;}

const int INF = 100000; 

int main(){
    int a, b;
    cin >> a >> b;

    if(a + b >= 24){
        cout << a + b - 24 << endl;
    }else{
        cout << a + b << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256