akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <math.h>
#include <limits>

using namespace std;

using ull = unsigned long long int;

int main()
{
    int N;
    cin >> N;
    ull a[N];
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }

    for (int i = 0; i < N; i++)
    {
        if (a[i] == 0)
        {
            cout << 0 << endl;
            return 0;
        }
    }

    ull ans = 1;
    ull lim = pow(10, 18);
    bool flag = false;
    for (int i = 0; i < N; i++)
    {
        if (!ans || a[i] <= std::numeric_limits<ull>::max() / ans)
        {
            ans *= a[i];
        }
        else
        {
            flag = true;
            break;
        }
        if (ans > lim)
        {
            flag = true;
            break;
        }
    }

    if (flag)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 4404
import java.io.*;
import java.util.*;
import static java.lang.Math.*;

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

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        String s = scanner.next();
        int w = scanner.nextInt();
        StringBuilder sb = new StringBuilder();
        int j = 0;
        for (int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            if (j == 0) {
                sb.append(ch);
            }
            j++;
            if (j == w) {
                j = 0;
            }
        }
        System.out.println(sb);
    }

    private class MyScanner {
        String[] s;int i;BufferedReader br;String reg = " ";
        MyScanner () { s = new String[0];i = 0;br = new BufferedReader(new InputStreamReader(System.in)); }
        public String next() {
            try {
                if (i < s.length) return s[i++]; String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0); i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}


Measured memory_bytes: 21204
#define _USE_MATH_DEFINES

#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

int main(){
	
	int N, A, B;
	cin >> N >> A >> B;
	
	cout << min(N * A, B) << endl;
	
	return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
s = input()
b = [1]
if s[0] == "0":
    b = [0, 1]
for i in range(1, n):
    if s[i-1] != s[i]:
        b += [1]
    else:
        b[-1] += 1
if s[-1] == "0":
    b += [0]
if len(b)//2 <= k:
    print(n)
    exit()

x = a = sum(b[:k*2+1])
for i in range(k, len(b)//2):
    a += b[i*2+1]+b[(i+1)*2]
    a -= b[(i-k)*2]+b[(i-k)*2+1]
    x = max(a, x)
print(x)


Measured memory_bytes: 4596
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(),a.end()
#define forn(i,n) for(int i=0;i<int(n);i++)
#define forr(i,n) for(int i=int(n-1);i>=0;i--)
#define fora(i,a,b) for(int i=int(a);i<=int(b);i++)
#define forb(i,a,b) for(int i=int(a);i>=int(b);i--)
#define mod 1000000007
using namespace std;
using ll=long long int;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<ll> vii;
typedef pair<ll ,ll> pii;
const int dx[]={-1,1,0,0};
const int dy[]={0,0,-1,1};
void solve()
{
	ll n;
	cin>>n;
	ll arr[n];
	forn(i,n)cin>>arr[i];
	ll pre[n];
	pre[0]=arr[0];
	fora(i,1,n-1)pre[i]=(pre[i-1]+arr[i])%mod;
	ll ans=0;
	for(int i=n-1;i>=1;i--)
	{
		ans+=arr[i]*pre[i-1];
		ans%=mod;
	}
	cout<<ans%mod<<endl;
	
}
int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    int t=1;
  //  cin>>t;
    while(t--)
	solve();
    return 0;
}


Measured memory_bytes: 6736
#include<bits/stdc++.h>
using namespace std;
#define ll  unsigned long long int
#define pb push_back
#define sx 300007
int main()
{
    int l,r,d,cnt=0;
    cin>>l>>r>>d;
    for(int i=l;i<=r;i++)
    {
        if(i%d==0)
            cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3540
#include <iostream>
#include <cstdlib>
#include <algorithm>

using namespace std;

long long xarr[50];
long long yarr[50];
long long x[50];
long long y[50];
int n;
int k;
long long squre;
int cmp(const void* x1,const void* x2)
{
    return *(int*)x1 - *(int*)x2;
}
int main()
{
    cin>>n>>k;
    for(int i = 0;i<n;i++){
        cin>>xarr[i]>>yarr[i];
    }
    for(int i = 0;i<n;i++){
        x[i]=xarr[i];
        y[i]=yarr[i];
    }
    qsort(xarr,n,sizeof(xarr[0]),cmp);
    qsort(yarr,n,sizeof(yarr[0]),cmp);
    /*
    for(int i = 0;i<n;i++){
        cout<<yarr[i]<<" ";
    }
    
    cout<<endl;
    */
    squre = 1LL * (xarr[n-1]-xarr[0]) * (yarr[n-1]-yarr[0]);
    for(int x1 = 0;x1<n;x1++){
        for(int x2 = x1+1;x2<n;x2++){
            for(int y1 = 0;y1<n;y1++){
                for(int y2 = y1+1;y2<n;y2++){
                    int cnt = 0;
                    for(int i = 0;i<n;i++){
                        if(x[i]>=xarr[x1] && x[i]<=xarr[x2] && y[i]>=yarr[y1] && y[i]<=yarr[y2])
                            cnt++;
                    }
                    if(cnt >=k){
                        squre = min(squre,1LL*(xarr[x2]-xarr[x1])*(yarr[y2]-yarr[y1]));
                    }
                }
            }
        }
    }
    cout<<squre<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<n+1;i++)

using namespace std;
using std::swap;

vector<long long int> p;
vector<long long int> q;

long long int ccd(long long int c, long long int d) {
	long long int x,r;
	x = c * d;
	r = d % c;
	while (r != 0) {
		d = c;
		c = r;
		r = d % c;
	}
	return x/c;
}

int main() {
	long long int a, b;
	long long int c, d;
	cin >> a >> b;
	cin >> c >> d;
	long long int ans_b,ans_a,lcm;
	if (c > d)lcm=ccd(d, c);
	else lcm=ccd(c, d);
	
	ans_b = b - b/c - b/d + b/lcm;
	ans_a = (a-1) - (a-1) / c - (a-1) / d + (a-1) / lcm;
	//cout << ans << "\n";
	cout << ans_b - ans_a << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
    ll t,m,n,k;
    t = 1;
    for(int i=0;i<t;i++)
    {
        cin>>n>>m>>k;
        ll arr[n],brr[m],prea[n+1],preb[m+1];
        prea[0] = preb[0] = 0;
        for(ll j=0;j<n;j++)
        {
            cin>>arr[j];
            prea[j+1] = prea[j]+arr[j];
        } 
        for(ll j=0;j<m;j++)
        {
            cin>>brr[j];
            preb[j+1] = preb[j]+brr[j];
        }
        ll maxi = 0;
        for(ll i=0;i<=n;i++)
        {
            for(ll j=m;j>=0;j--)
            {
                if(prea[i]+preb[j]<=k)
                {
                    maxi = max(maxi,i+j);
                    m = j;
                    break;
                }
            }
        }
        cout<<maxi;
    }
    return 0;
}

Measured memory_bytes: 9876
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

int D[33][33];
int c[505][505];


int sum[3][505];

int main(){
  int N,C;
  cin >> N >> C;
  for(int i = 0;i < C;i++){
    for(int j = 0;j < C;j++){
      cin >> D[i][j];
    }
  }

  for(int i = 0;i < N;i++){
    for(int j = 0;j < N;j++){
      cin >> c[i][j];
      c[i][j]--;
    }
  }

  for(int i = 0;i < N;i++){
    for(int j = 0;j < N;j++){
      for(int to = 0;to < C;to++){
        sum[(i + 1 + j + 1) % 3][to] += D[c[i][j]][to];
      }
    }
  }
  int ans = 1e9;
  rep(i,0,C - 1)rep(j,0,C - 1)rep(k,0,C - 1){
    if(i == j || j == k || k == i) continue;
    ans = min(ans , sum[0][i] + sum[1][j] + sum[2][k]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1280
package main

import (
	"fmt"
)

type ll int64

type part_time_job struct {
	days ll
	paid ll
}

type Bydays []part_time_job
func (a Bydays) Len() int           { return len(a) }
func (a Bydays) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a Bydays) Less(i, j int) bool { return a[i].days <  a[j].days }

type Bypaid []part_time_job
func (a Bypaid) Len() int           { return len(a) }
func (a Bypaid) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a Bypaid) Less(i, j int) bool { return a[i].paid > a[j].paid }


func main() {

	var N ll
	fmt.Scan(&N)

	var leftHeight ll = 0
	var nowHeight ll = 0
	var moves ll = 0
	var ans ll = 0

	var i ll
	for i = 0 ; i < N ; i++ {
		fmt.Scan(&nowHeight)
		if nowHeight <=  leftHeight {//左のマスの方が高い場合
			moves++
		}else{//今のマスの方が高い場合
			if ans <= moves {//最大移動距離の更新
				ans = moves
			}
			moves = 0
		}
		leftHeight = nowHeight
	}

	if moves >= ans {
		ans = moves
	}

	//最後moves と ans　の比較を行う

	fmt.Println(ans)



}


Measured memory_bytes: 5504
nums = input()
 
N = 3
for i in range(2**N):
    equation = ''
    for j in range(N):
        equation += nums[j]
        if ((i >> j) & 1):
            equation += '+'
        else:
            equation += '-'
    equation += nums[-1]
    if eval(equation) == 7:
        print(equation + '=7')
        exit()

Measured memory_bytes: 9128
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;

int main()
{
	bool isshow = false;

	int H,W,K;
	cin>>H>>W>>K;
	vector<vector<bool>> p(H);
	vector<vector<int>> ans(H);
	for(int i=0; i<H; i++)
	{
		p[i].resize(W);
		ans[i].resize(W);
	}

	for(int i=0; i<H; i++)
	{
		for(int j=0; j<W; j++)
		{
			char _c;
			cin>>_c;
			if(_c=='#')
			{
				p[i][j] = true;
			}
			else
			{
				p[i][j] = false;
			}
			ans[i][j] = 0;
		}
	}
	int stamp = 1;
	for(int i=0; i<H; i++)
	{
		//列走査
		int count = 0;
		for(int j=0; j<W; j++)
		{
			if(p[i][j])
			{
				count++;
			}
		}
		if(count > 0)
		{
			isshow = true;
			for(int j=0; j<W; j++)
			{
				ans[i][j] = stamp;
				if(p[i][j])
				{
					stamp++;
				}
				
			}
			for(int j=W-1; j>=0; j--)
			{
				if(p[i][j])
				{
					break;
				}
				ans[i][j]--;
				
				
			}
		}
		else
		{
			if(!isshow)
			{
				continue;
			}
			for(int j=0; j<W; j++)
			{
				ans[i][j]=ans[i-1][j];
			}
		}
	}

	for(int i=H-1; i>=0; i--)
	{
		for(int j=0; j<W; j++)
		{
			if(ans[i][j] == 0)
			{
				ans[i][j] = ans[i+1][j];
			}
		}
	}

	for(int i=0; i<H; i++)
	{
		for(int j=0; j<W; j++)
		{
			cout<<ans[i][j]<<" ";
		}
		cout<<endl;
	}

}

Measured memory_bytes: 1152
import java.util.*;

class Main{
    static Scanner sc = new Scanner(System.in);
    public static void main(String args[]){
        int N=sc.nextInt(),max=0;
        String S=sc.next();
        HashMap<String,Integer>x=new HashMap<>(),y=new HashMap<>();
        for(int i=0;i<N;i++){
            String T=String.valueOf(S.charAt(i));
            if(!x.containsKey(T)){
                x.put(T,1);
            }else{
                x.put(T,x.get(T)+1);
            }
        }
        for(int i=0;i<N;i++){
            String T=String.valueOf(S.charAt(i));
            if(!y.containsKey(T)){
                y.put(T,1);
            }
            else{
                y.put(T,y.get(T));
            }
            x.put(T,x.get(T)-1);
            if(x.get(T)==0){
                x.remove(T);
                y.remove(T);
            }
            max=Math.max(max,Math.min(x.size(),y.size()));
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 35692
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    //99以下は8%なし、9以下は10%なし
    for(int i=0;i<=1100;i++){
        if(int(i*0.08)==a&&int(i*0.1)==b){
            printf("%d",i);
            return 0;
        }
    }
    printf("-1");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;

int main(){
    int n, y; 
    cin >> n >> y;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            int k = n - i - j;
            if (k >= 0 && k <= n) {
                if (i * 10000 + j * 5000 + k * 1000 == y) {
                    cout << i << ' ' << j << ' ' << k << endl;
                    return 0;
                }
            }
        }
    }
    cout << "-1 -1 -1" << endl;
}


Measured memory_bytes: 3592
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		 Scanner scan = new Scanner(System.in);
	        int N  = scan.nextInt();

	        List<Integer> x = new ArrayList<Integer>();
	        List<Integer> y = new ArrayList<Integer>();

	        for(int i=0;i<N;i++) {
	        	x.add(scan.nextInt());
	        	y.add(x.get(i));
	        }
	        x.sort((o1,o2)->o2.compareTo(o1));
	        int max = x.get(0);
	        int max2 = x.get(1);



	        for(int i=0;i<N;i++) {
	        	if(max == y.get(i)) {
	    	        System.out.println(String.valueOf(max2));
	        	}else {
	    	        System.out.println(String.valueOf(max));

	        	}
	        }
	}

}


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

typedef long long int int64;

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

#define POS(i,j) ((i)*(n+1)+(j))

int64 calc(int l,int r,int *a,int64 *dp,int *end,int n){
  if(r==l) return 0;
  if(end[POS(l,r)]) return dp[POS(l,r)];
  if(n%2==(r-l)%2){
    dp[POS(l,r)]=MAX(calc(l+1,r,a,dp,end,n)+a[l],calc(l,r-1,a,dp,end,n)+a[r-1]);
  } else {
    dp[POS(l,r)]=MIN(calc(l+1,r,a,dp,end,n)-a[l],calc(l,r-1,a,dp,end,n)-a[r-1]);
  }
  end[POS(l,r)]=1;
  return dp[POS(l,r)];
}

void run(void){
  int n;
  scanf("%d",&n);
  int *a=(int *)calloc(n,sizeof(int));
  int i;
  for(i=0;i<n;i++) scanf("%d",a+i);
  int64 *dp=(int64 *)calloc((n+1)*(n+1),sizeof(int64));
  int *end=(int *)calloc((n+1)*(n+1),sizeof(int));
  int64 ans=calc(0,n,a,dp,end,n);
  printf("%lld\n",ans);
}

int main(void){
  run();
  return 0;
}


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

using namespace std;

#define li long long int

const int N 	= 2e1 + 2;
const li mod 	= 1e9 + 7;

int n;
int a[N][N];
li dp[N][1 << N];

li go(int idx, int mask) {
	if (idx >= n) return mask == (1 << n) - 1;
	if (dp[idx][mask] != -1) return dp[idx][mask];
	li ans = 0;
	for (int i = 0; i < n; i++) {
		if (a[idx][i] and !(mask & (1 << i))) {
			ans += go(idx + 1, mask ^ (1 << i));
			ans %= mod;
		}
	}
	return dp[idx][mask] = ans;
} 

void solve() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}
	memset(dp, -1, sizeof(dp));
	li ans = go(0, 0);
	cout << ans;
} 

int main() {
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i < b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = INT_MAX / 2;
const ll  inf = LLONG_MAX / 2;
const int mod = 1000000007;
const int MAX_N = 101010;
const long double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	int n;
	cin >> n;
	string s;
	cin >> s;

	map<char, int> mp;
	rep(i, sz(s)) {
		mp[s[i]]++;
	}
	ll ans = 1;
	for (auto m : mp) {
		ans *= m.second + 1;
		ans %= mod;
	}

	out(ans - 1);

	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int max=-1000000000,res,min=0,num;
        int n=sc.nextInt();
        for(int i=0;i<n;i++){
            num=sc.nextInt();
            if(i==0){
                min=num;
            }else{
                res=num-min;
                if(res>max){
                    max=res;
                }
                if(min>num){
                    min=num;
                }
            }
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 69144
#include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define pi 3.14159265358979
int main() {
	int h, w;
	while (1) {
		cin >> h >> w;
		if (h == 0 && w == 0)break;
		rep(i, h) {
			rep(j, w) {
				if (i == 0 || j == 0 || i == h - 1 || j == w - 1)cout << "#";
				else cout << ".";
			}
			cout << endl;
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 3088
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
using namespace std;

int main(){
    int a,b;cin>>a>>b;
    if(a%2==1&&b%2==1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

using i64 = long long;
using P = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()

struct IoSetup {
    IoSetup() {
        // cin.tie(nullptr);
        // ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main(){
    i64 n;
    cin >> n;
    i64 ans, c;
    ans = 1, c = 0;
    rep(i, 1, n + 1){
        i64 cnt = 0, tmp = i;
        while(tmp % 2 == 0){
            tmp /= 2;
            ++cnt;
        }
        if(cnt > c){
            ans = i;
            c = cnt;
        }
    }
    cout << ans << endl;
    return 0;
}


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

constexpr int inf = 1e9;

int main() {
    int n, m; cin >> n >> m;
    vector<int> b(n), p(m);
    for(int i = 0; i < n; ++i) {
        cin >> b[i];
    }
    for(int i = 0; i < m; ++i) {
        cin >> p[i];
    }

    auto solve = [&] (int st) {
        auto a = b;
        int res = 0;
        for(int i = 0, pos = 0; i < m; ++i) {
            for(int j = 0; j < p[i]; ++j, ++pos) {
                const int k = find(begin(a) + pos, end(a), st) - begin(a);
                if(k == n) return inf; // no solution
                res += k - pos;
                for(int l = k; l - 1 >= pos; --l) {
                    swap(a[l - 1], a[l]);
                }
            }
            st = !st;
        }
        return res;
    };

    cout << min(solve(0), solve(1)) << endl;
}



Measured memory_bytes: 3160
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    for(int bit = 0; bit < (1<<n); bit++)
    {
        vector<int> v;
        for(int i = 0; i < n; i++)
        {
            if(bit & (1<<i)) v.push_back(i);
        }
        if(v.size() == k)
        {
            cout << bit << ":";
            for(int i = 0; i < v.size(); i++) cout << " " << v[i];
            cout << endl;
        }
    }
    return 0;
}




Measured memory_bytes: 3212
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl
const ll MAX_10p5 = 100010;
const ll MAX_10p9 = 1000000010;
const ll MAX_10p18 = 1000000000000000010;
const ll MOD = 1000000007;
struct edge {
	ll to, cost;
	bool operator<(const edge& right) const {
		return cost == right.cost ? to < right.to : cost < right.cost;
	}
};

///////////////////////////////////////////////////////////////////////////////////////

ll N, a[3 * MAX_10p5];
ll rightarrowSum[MAX_10p5], leftarrowSum[MAX_10p5];
ll ans = -MAX_10p18;
priority_queue<ll> rightarrowQ, leftarrowQ;

int main() {
	rd(N);
	ll temp = 0;

	repi(i, 0, 3 * N) rd(a[i]);

	repi(i, 0, N) {
		rightarrowSum[0] += a[i];
		rightarrowQ.push(-a[i]);
		leftarrowSum[0] += a[3 * N - 1 - i];
		leftarrowQ.push(a[3 * N - 1 - i]);
	}
	repi(i, 1, N + 1) {
		rightarrowQ.push(-a[N - 1 + i]);
		rightarrowSum[i] = rightarrowSum[i-1] + a[N - 1 + i] + rightarrowQ.top();
		rightarrowQ.pop();
		leftarrowQ.push(a[2 * N - i]);
		leftarrowSum[i] = leftarrowSum[i - 1] + a[2 * N - i] - leftarrowQ.top();
		leftarrowQ.pop();
	}
	repi(i, 0, N + 1) ans = max(ans, rightarrowSum[i] - leftarrowSum[N - i]);

	wrln(ans);

	return 0;
}


Measured memory_bytes: 5996
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
double n,power,c=27.0,ans;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n;
	power=n*n*n;
	ans=power/c;
	printf("%.12lf",ans);
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
#include<iterator>
#include<queue>
#include<stack>
#include<cctype>
#include<deque>
#include<time.h>
#include<bitset>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<sstream>
#include<random>
#include<numeric>
//by Skeef79

typedef long long ll;
typedef long double ld;

typedef unsigned long long ull;

#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#define pb push_back
#define en '\n'
#define for0(i,n) for(int i = 0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>
#define SZ(a) int(a.size())

using namespace std;

const int INF = 2000000000;
const ll LINF = 2000000000000000000;

template<typename T> void print(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

template <typename T> void input(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
		for (int j = 0; j < a[i].size(); j++)
			cin >> a[i][j];

}

int maxAbsValExpr(vector<int>& x, vector<int>& y) {
	int res = 0, n = x.size(), smallest, cur;
	for (int p : {1, -1}) {
		for (int q : {1, -1}) {
			smallest = p * x[0] + q * y[0] + 0;
			for (int i = 1; i < n; ++i) {
				cur = p * x[i] + q * y[i];
				res = max(res, cur - smallest);
				smallest = min(smallest, cur);
			}
		}
	}
	return res;

}

void solve()
{
	int n;
	cin >> n;

	vector<int>a(n);
	vector<int>b(n);
	for (int i = 0; i < n; i++)
	{
		int x, y;
		cin >> x >>y;
		a[i] = x;
		b[i] = y;
	}

	cout << maxAbsValExpr(a, b);
}

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

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif

	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);

	int tst = 1;
	//cin >> tst;

	while (tst--)
		solve();
}


Measured memory_bytes: 4764
#include <bits/stdc++.h>
//#include<fstream>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
#define endl '\n'
#define pb push_back
#define fi first
#define se second
typedef long long ll;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define all(con) con.begin(),con.end()
#define w(x) int x; cin>>x; while(x--)
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

/*ofstream fout("bcount.out");
ifstream fin("bcount.in");*/

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    cout<<fixed<<setprecision(8);
    string s;
    cin>>s;
    if(s.back() == 's')
    {
        string ans;
        rep(i,0,(int)s.length())
            ans += s[i];
        ans += "es";
        cout<<ans<<endl;
    }
    else
    {
        s += 's';
        cout<<s<<endl;
    }
    return 0;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int keta(int x) {
  if (x == 0) return 0;
  return 1 + keta(x / 10);
}

void solve() {
  int n, m;
  cin >> n >> m;
  vector<int> s(m), c(m);
  rep(i,m) cin >> s[i] >> c[i];
  for (int i = 0; i < 1000; i++) {
    string t = to_string(i);
    if (t.size() != n) continue;
    bool b = true;
    rep(j,m) {
      if (t[s[j] - 1] != (char) c[j] + '0') b = false;
    }
    if (b) {
      cout << i << endl;
      return;
    }
  }
  cout << -1 << endl;
}

int main() {
  solve();
  return 0;
}

Measured memory_bytes: 3592
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to;
	ld cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y, h;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
ll fact(ll x, ll k) {//最大値、個数
	ll sum = 1;
	for (int i = 0; i < k; i++)
		sum *= (x--);
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}
#define int long long
const long long inf = 4523372036854775807;
const int iinf = 1500000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
int m, sum, n;
signed main() {
	cin >> m;
	string h = "", s = to_string(m);
	n = s.size();
	int ans = 0, ma = 0;
	for (int i = 0; i < n; i++) {
		h += '9';
		ans += 9;
		ma += (int)s[i] - '0';
	}
	for (int i = 0; i < n; i++) {
		h = "";
		ans = 0;
		for (int i = 0; i < n; i++) {
			h += '9';
			ans += 9;
		}
		for (int z = i; z < n; z++) {
			ans -= 9;
			for (int j = 0; j < 10; j++) {
				h[i] = (char)j + '0';
				if (stoll(h) <= m) {
					ma = max(ans + j, ma);
				}
			}
		}
	}
	cout << ma << endl;
	getchar(); getchar();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int c,d;
  int count=0;
  for(int i=0;i<n;i++)
  {
    cin>>c>>d;
    if(c==d)
    {
      count++;
      if(count==3)
      {
        cout<<"Yes";
        return 0;
      }
    }
    else
      count=0;
  }
  cout<<"No";
  return 0;
}

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

int main() {
	ios::sync_with_stdio(false);
	long long a, b, c, d;
	int e(-1), f(-1), g(-1), h(-1);
	vector<long long> ar;
	cin >> a >> b >> c >> d;
	ar.push_back(a); ar.push_back(b); ar.push_back(c); ar.push_back(d);
	for (int i(0); i < 4; ++i) {
		switch (ar[i]) {
		case 1: ++e; break;
		case 9: ++f; break;
		case 7: ++g; break;
		case 4: ++h; break;

		}
	}
	if (e == 0 && f == 0 && g == 0 && h == 0) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        char ch[] = S.toCharArray();
        int N = S.length();
        int count = 0;
        for(int i = 0; i <= N/2-1; i++) {
        	if(ch[i] != ch[N-1-i]) {
        		count++;
        	}
        }
        System.out.println(count);
    
    }
}

Measured memory_bytes: 23124
n = int(input())
ret = 0

for i in range(n+1):
  """
  if i % 3 == 0 and i % 5 == 0:
    ret.append('FizzBuzz')
  elif i % 3 == 0:
    ret.append('Fizz')
  elif i % 5 == 0:
    ret.append('Buzz')
 
  else:
  """
  if  i % 3 != 0 and i % 5 != 0:
    ret += i
print(ret)

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

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

using namespace std;

int n,bad[100000],deg[100000],ans[100000];

set<int> V; // unused vertices (and a centinel)
set<pair<int,int>> Deg; // (degree, vertex)

bool dfs(int i){
	if(i==n) return true;

	int x=Deg.rbegin()->second;
	if(deg[x]==n-i-1){
		if(i==0 || bad[ans[i-1]]!=x){
			int y=bad[x];
			bool b=V.count(y);

			Deg.erase({deg[x],x});
			if(b){
				Deg.erase({deg[y],y});
				deg[y]--;
				Deg.emplace(deg[y],y);
			}
			V.erase(x);

			ans[i]=x;
			if(dfs(i+1)) return true;

			V.emplace(x);
			if(b){
				Deg.erase({deg[y],y});
				deg[y]++;
				Deg.emplace(deg[y],y);
			}
			Deg.emplace(deg[x],x);
		}
		return false;
	}

	for(int x=*V.begin();x<n;x=*V.upper_bound(x)){
		if(i==0 || bad[ans[i-1]]!=x){
			int y=bad[x];
			bool b=V.count(y);

			Deg.erase({deg[x],x});
			if(b){
				Deg.erase({deg[y],y});
				deg[y]--;
				Deg.emplace(deg[y],y);
			}
			V.erase(x);

			ans[i]=x;
			if(dfs(i+1)) return true;

			V.emplace(x);
			if(b){
				Deg.erase({deg[y],y});
				deg[y]++;
				Deg.emplace(deg[y],y);
			}
			Deg.emplace(deg[x],x);
		}
	}
	return false;
}

int main(){
	scanf("%d",&n);
	rep(i,n) scanf("%d",&bad[i]), bad[i]--;

	rep(i,n+1) V.emplace(i);
	rep(i,n) deg[bad[i]]++;
	rep(i,n) Deg.emplace(deg[i],i);

	if(dfs(0)){
		rep(i,n) printf("%d%c",ans[i]+1,i<n-1?' ':'\n');
	}
	else{
		puts("-1");
	}

	return 0;
}


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

#define ll long long

signed main()
{
  int x,y,ok=0; cin>> x >> y;
  for(int i=0; i<x; ++i){
    if(2*i + 4*(x-i) == y || 4*i + 2*(x-i) == y){
      cout << "Yes";
      return 0;
    }
  }
  cout << "No";
  return 0;
}

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

int main() {
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int x=c-a;
	int y=d-b;
	int x3,x4,y3,y4;
	x3 = c - y;
	y3 = d + x;
	x4 = x3 - x;
	y4 = y3 - y;
	cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;cin>>n;
    vector<int> p(n);
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    int ans=0;
    sort(p.begin(),p.end());
    for(int i=0;i<n-1;i++){
        ans+=p[i];
    }
    ans+=p[n-1]/2;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<math.h>
#include<queue>
#include<cstdio>
#include<set>
#include<map>
using namespace std;

int main(){
    vector<int> A(9);
    for(int i=0; i<9; i++){
        cin >> A.at(i);
    }
    int N;
    cin >> N;
    vector<int> B(N);
    for(int i=0; i<N; i++){
        cin >> B.at(i);
    }
    vector<int> C(9,0);
    for(int i=0; i<N; i++){
        for(int j=0; j<9; j++){
            if(A.at(j)==B.at(i)) C.at(j)=1;
        }
    }
    if(C.at(0)*C.at(1)*C.at(2)+C.at(3)*C.at(4)*C.at(5)+C.at(6)*C.at(7)*C.at(8)+C.at(0)*C.at(3)*C.at(6)+C.at(1)*C.at(4)*C.at(7)+C.at(2)*C.at(5)*C.at(8)+C.at(0)*C.at(4)*C.at(8)+C.at(2)*C.at(4)*C.at(6)==0) cout << "No";
    else cout << "Yes";
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.S;
		var t=sc.S;
		int ans=int.MaxValue;
		for(int i = 0;i<=s.Length-t.Length;i++) {
			int p=t.Length;
			for(int j = 0;j<t.Length;j++) {
				if(s[i+j]==t[j]){p--;}
			}
			ans=Min(ans,p);
		}
		Console.WriteLine("{0}",ans);
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),int.Parse);}
	public int[] Ia3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),long.Parse);}
	public long[] La3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 25968
#include <stdio.h>
#include <math.h>

struct Point
{
    double x, y;
};

void koch(int n, Point a, Point b)
{
    if (n == 0)
        return;
    Point s, t, u;
    double th = M_PI * 60.0 / 180.0;

    s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
    s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
    t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
    t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
    u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

    koch(n - 1, a, s);
    printf("%.8f %.8f\n", s.x, s.y);
    koch(n - 1, s, u);
    printf("%.8f %.8f\n", u.x, u.y);
    koch(n - 1, u, t);
    printf("%.8f %.8f\n", t.x, t.y);
    koch(n - 1, t, b);
}

int main()
{
    Point a, b;
    int n;

    scanf("%d", &n);

    a.x = 0;
    a.y = 0;
    b.x = 100;
    b.y = 0;

    printf("%.8f %.8f\n", a.x, a.y);
    koch(n, a, b);
    printf("%.8f %.8f\n", b.x, b.y);

    return 0;
}


Measured memory_bytes: 2704
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC116_C solver = new ABC116_C();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC116_C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int h[] = new int[n];
            int ans = 0;
            int max = 0;
            for (int i = 0; i < n; i++) {
                h[i] = in.nextInt();
                max = Math.max(max, h[i]);
            }
            int startIndex = 0;
            int endIndex = h.length - 1;
            for (int i = startIndex; i <= endIndex; i++) {
                if (h[i] != 0) {
                    startIndex = i;
                    break;
                }
            }

            for (int i = endIndex; startIndex <= i; i--) {
                if (h[i] != 0) {
                    endIndex = i;
                    break;
                }
            }
            boolean repeatingZero = false;
            while (max > 0) {
                for (int i = startIndex; i <= endIndex; i++) {
                    if (h[i] == 0 && !repeatingZero) {
                        ans++;
                        repeatingZero = true;
                    }

                    if (h[i] != 0 && repeatingZero) {
                        repeatingZero = false;
                    }

                    if (h[i] > 0) {
                        h[i]--;
                    }
                }

                ans++;

                for (int i = startIndex; i <= endIndex; i++) {
                    if (h[i] != 0) {
                        startIndex = i;
                        break;
                    }
                }

                for (int i = endIndex; startIndex <= i; i--) {
                    if (h[i] != 0) {
                        endIndex = i;
                        break;
                    }
                }

                max--;
            }

            out.print(ans);

        }

    }
}



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

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

// a^{-1} mod を計算する
long modinv(long a, long mod) {
    return modpow(a, mod - 2, mod);
}

struct compare1 { 
    bool operator()(const pair<long, long>& value,  
                                const long& key) 
    { 
        return (value.first < key); 
    } 
    bool operator()(const long& key,  
                    const pair<long, long>& value) 
    { 
        return (key < value.first); 
    } 
}; 

int main()
{
    string s; cin >> s;
    if(s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;

    
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
  
int main(int argc, char *argv[]) {
    int h, w;
    char s[50][50];
    char tmp;


    scanf("%d%d", &h, &w);
    scanf("%c", &tmp);

    for (int j = 0; j < h; j++) {
        for (int i = 0; i < w; i++) {
            scanf("%c", &s[j][i]);
        }
        scanf("%c", &tmp);
    }


    for (int j = 0; j < h; j++) {
        for (int i = 0; i < w; i++) {
            if (s[j][i] == '#') {
                if (
                       s[j > 0 ? j - 1 : j + 1][i]     == '#'
                    || s[j < h - 1 ? j + 1 : j - 1][i] == '#'
                    || s[j][i > 0 ? i - 1 : i + 1]     == '#'
                    || s[j][i < w - 1 ? i + 1 : i - 1] == '#') {
                } else {
                    printf("No\n");
                    return 0;
                }
            }
        }
    }

    printf("Yes\n");

    return 0;
}

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

using namespace std;

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

  int ans = 1;
  for(int i=1; i<s.size(); i++){
    if( s.at(i-1) != s.at(i) ){
      ans += 1;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>

int main()
{
	double x1,x2,x3,y1,y2,y3,r,xp,yp;
	int n,i;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3);
		xp=((y2-y3)*(x1*x1+y1*y1)+(y3-y1)*(x2*x2+y2*y2)+(y1-y2)*(x3*x3+y3*y3))/(2*(x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2)));
		yp=((x2-x3)*(x1*x1+y1*y1)+(x3-x1)*(x2*x2+y2*y2)+(x1-x2)*(x3*x3+y3*y3))/(2*(y1*(x2-x3)+y2*(x3-x1)+y3*(x1-x2)));
		r=sqrt((x1-xp)*(x1-xp)+(y1-yp)*(y1-yp));
		printf("%.3lf %.3lf %.3lf\n",xp,yp,r);
	}
	return 0;
}

Measured memory_bytes: 0
N = int(input())
deg = [0 for _ in range(N)]
edges = [[] for _ in range(N - 1)]
a = []
for i in range(N - 1):
    in1, in2 = map(int, input().split())
    a.append([in1, in2, i])
a = sorted(a, key = lambda x: x[0])
for i in range(N - 1):
    edges[i] = [a[i][0] - 1, a[i][1] - 1, a[i][2]]
    deg[a[i][0] - 1] += 1
    deg[a[i][1] - 1] += 1
deg_max = max(deg)
print(deg_max)

co = [0 for _ in range(N)]
ans = [0 for _ in range(N - 1)]
for i in range(N - 1):
    a = edges[i][0]
    b = edges[i][1]
    temp = 1 + (co[a] % deg_max)
    co[a] = temp
    co[b] = temp
    ans[edges[i][2]] = temp
for i in range(N - 1):  print(ans[i])

Measured memory_bytes: 120196
def main():
    N, M = (int(i) for i in input().split())
    ans = 0
    if N == 1 and M == 1:
        ans = 1
    elif N == 1:
        ans = M-2
    elif M == 1:
        ans = N-2
    else:
        h = N-2
        w = M-2
        ans = h*w
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
import os
import sys
from collections import deque

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N, M = list(map(int, sys.stdin.readline().split()))
AB = [list(map(int, sys.stdin.readline().split())) for _ in range(M)]
graph = [[] for _ in range(N + 1)]

for a, b in AB:
    graph[a].append(b)


def cycle_size(from_v):
    """

    :param from_v:
    :return:
    """
    parents = [None] * len(graph)
    seen = [False] * len(graph)
    que = deque([(from_v, 0)])
    while que:
        v, d = que.pop()
        for u in graph[v]:
            if seen[u]:
                continue
            seen[u] = True
            que.appendleft((u, d + 1))
            parents[u] = v
            if u == from_v:
                return d + 1, parents
    return INF, parents


min_v = None
min_size = INF
min_parents = None
for v in range(1, N + 1):
    size, parents = cycle_size(v)
    if size < min_size:
        min_v = v
        min_size = size
        min_parents = parents

if min_size < INF:
    print(min_size)
    print(min_v)
    v = min_parents[min_v]
    while v != min_v:
        print(v)
        v = min_parents[v]
else:
    print(-1)


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


int main(){
    int A, B, Q;
    vector<Int> S(100010, -1e11), T(100010, -1e11);

    cin >> A >> B >> Q;
    rep(i, A) cin >> S[i+1];
    rep(i, B) cin >> T[i+1];
    sort(S.begin(), S.begin()+A+1);
    sort(T.begin(), T.begin()+B+1);
    S[A+1] = 1e11; T[B+1] = 1e11;

    rep(query, Q){
        Int x; cin >> x;

        Int rightS = *lower_bound(S.begin(), S.begin()+A+2, x);
        Int leftS = *(lower_bound(S.begin(), S.begin()+A+2, x)-1);
        Int rightT = *lower_bound(T.begin(), T.begin()+B+2, x);
        Int leftT = *(lower_bound(T.begin(), T.begin()+B+2, x)-1);
        //cout << rightS << " " << leftS << " " << rightT << " " << leftT << endl;
        
        Int rSrT = max(rightS, rightT) - x;
        Int rSlT = 2*min(x-leftT, rightS-x)+max(x-leftT, rightS-x);
        Int lSrT = 2*min(x-leftS, rightT-x)+max(x-leftS, rightT-x);
        Int lSlT = x - min(leftS, leftT);

        cout << min(rSrT, min(rSlT, min(lSrT, lSlT))) << endl;
    }
}

Measured memory_bytes: 2944