akhauriyash/Code-Regression huggingface dataset:
import sys
import math
import copy
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

class BIT():
    # A1 ... AnのBIT(1-indexed)
    def __init__(self, n):
        self.n = n
        self.BIT = [0] * (n + 2)

    # A1 ~ Aiまでの和 O(logN)
    def query(self, idx):
        res_sum = 0
        while idx > 0:
            res_sum += self.BIT[idx]
            idx -= idx & (-idx)
        return res_sum

    # Ai += x O(logN)
    def update(self, idx, x):
        # print(idx)
        while idx <= self.n:
            # print(idx)
            self.BIT[idx] += x
            idx += idx & (-idx)
        return

    def show(self):
        print(self.BIT)

def cost(id, div, x):
    n = len(div)
    use = []
    for i in range(n):
        if id % 2 == 1:
            use.append(div[i])
        id //= 2

    return (len(use) - 1) * 10 + abs(x - sum(use))


def eachtake(div, x):
    n = len(div)
    ret = INF

    for id in range(1, 1 << n):
        tmp = cost(id, div, x)
        ret = min(tmp, ret)

    return ret


def eachpat(pat, a, b, c, li, n):
    div = [[] for i in range(3)]
    for i in range(n):
        if pat % 4 != 3:
            div[pat%4].append(li[i])
        pat //= 4

    for i in range(3):
        if not div[i]:
            return INF

    ret = 0
    ret += eachtake(div[0], a)
    ret += eachtake(div[1], b)
    ret += eachtake(div[2], c)
    
    return ret


def solve():
    n, a, b, c = getList()
    li = []
    for i in range(n):
        li.append(getN())

    ans = INF
    for pat in range(4 ** n):
        tmp = eachpat(pat, a, b, c, li, n)
        ans = min(ans, tmp)

    print(ans)

def main():
    n = getN()
    for _ in range(n):
        solve()

    return
if __name__ == "__main__":
    # main()
    solve()
    # print(eachtake([333], 100))

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

typedef pair<ll, ll> P;


int main() {
    ll a,b,k; cin >> a >> b >> k;
    vector<ll> ans;
    FOR(i, a, min(k+a, b)) ans.push_back(i);
    EFOR(i, max(a, b-k+1), b) ans.push_back(i);
    sort(ans.begin(), ans.end());
    ans.erase(unique(ans.begin(), ans.end()), ans.end());

    rep(i, ans.size()) {
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 256
S = input()
K = int(input())
n = len(S)

dp = [[[0 for _ in range(2)] for _ in range(4)] for _ in range(10001)]

dp[0][0][0] = 1
for i in range(n):
    for j in range(4):
        for k in range(2):
            nd = int(S[i])
            for d in range(10):
                ni = i + 1
                nj = j
                nk = k
                if d != 0:
                    nj += 1
                if nj > K:
                    continue
                if k == 0:
                    if d > nd:
                        continue
                    if d < nd:
                        nk = 1
                dp[ni][nj][nk] += dp[i][j][k]

ans = dp[n][K][0] + dp[n][K][1]

print(ans)


Measured memory_bytes: 49244
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		int[] cnt = new int[26];
		for (int i=0;i<N;i++) {
			if (S.charAt(i)=='a') {
				cnt[0]++;
			}else if(S.charAt(i)=='b') {
				cnt[1]++;
			}else if(S.charAt(i)=='c') {
				cnt[2]++;
			}else if(S.charAt(i)=='d') {
				cnt[3]++;
			}else if(S.charAt(i)=='e') {
				cnt[4]++;
			}else if(S.charAt(i)=='f') {
				cnt[5]++;
			}else if(S.charAt(i)=='g') {
				cnt[6]++;
			}else if(S.charAt(i)=='h') {
				cnt[7]++;
			}else if(S.charAt(i)=='i') {
				cnt[8]++;
			}else if(S.charAt(i)=='j') {
				cnt[9]++;
			}else if(S.charAt(i)=='k') {
				cnt[10]++;
			}else if(S.charAt(i)=='l') {
				cnt[11]++;
			}else if(S.charAt(i)=='m') {
				cnt[12]++;
			}else if(S.charAt(i)=='n') {
				cnt[13]++;
			}else if(S.charAt(i)=='o') {
				cnt[14]++;
			}else if(S.charAt(i)=='p') {
				cnt[15]++;
			}else if(S.charAt(i)=='q') {
				cnt[16]++;
			}else if(S.charAt(i)=='r') {
				cnt[17]++;
			}else if(S.charAt(i)=='s') {
				cnt[18]++;
			}else if(S.charAt(i)=='t') {
				cnt[19]++;
			}else if(S.charAt(i)=='u') {
				cnt[20]++;
			}else if(S.charAt(i)=='v') {
				cnt[21]++;
			}else if(S.charAt(i)=='w') {
				cnt[22]++;
			}else if(S.charAt(i)=='x') {
				cnt[23]++;
			}else if(S.charAt(i)=='y') {
				cnt[24]++;
			}else if(S.charAt(i)=='z') {
				cnt[25]++;
			}
		}
		long sum = (long)0;
		for (int i=0;i<26;i++) {
			if (cnt[i]>=1) {
				sum+=(sum+1)*cnt[i];
			}
			if (sum>1000000007) {
				sum%=1000000007;
			}
		}
		System.out.println(sum%1000000007);
	}
}

Measured memory_bytes: 25668
#include<bits/stdc++.h>
using namespace std;
long long int a[100200][2];
long long int dp[110][100200];
int main()
{
    int n,w;
    
    cin >> n >> w;
    
    for(int i=0;i<n;i++)
    {
        cin >> a[i][0] >> a[i][1]; 
    }

    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=w;j++)
        if(i==0 || j==0)
        {
            dp[i][j]=0;
        }    
        else if(a[i-1][0]<=j)
        {
            dp[i][j]=max(dp[i-1][j],dp[i-1][j-a[i-1][0]]+a[i-1][1]);
        }
        else
        {
            dp[i][j]=dp[i-1][j];
        }
    }

    cout << dp[n][w] << endl;
    return 0;
}

Measured memory_bytes: 80128
import sys
from math import ceil, floor
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def main():
    x = int(input())
    cnt = 0
    if x >= 500:
        cnt += (x // 500) * 1000
        x %= 500
    if x >= 5:
        cnt += (x// 5)*5
        x %= 5 
    print(cnt)
    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 5584
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sc.close();

        // 主処理
        String[] arr = s.split("");
        int[] nums = new int[4];
        for (int i = 0; i < nums.length; i++) {
            nums[i] = Integer.parseInt(arr[i]);
        }

        String result = "";
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < 2; j++) {
                for (int j2 = 0; j2 < 2; j2++) {
                    int ans = nums[0];
                    ans = i == 0 ? ans + nums[1] : ans - nums[i];
                    ans = j == 0 ? ans + nums[2] : ans - nums[2];
                    ans = j2 == 0 ? ans + nums[3] : ans - nums[3];
                    if (ans == 7) {
                        String op1 = i == 0 ? "+" : "-";
                        String op2 = j == 0 ? "+" : "-";
                        String op3 = j2 == 0 ? "+" : "-";
                        result = nums[0] + op1 + nums[1] + op2 + nums[2] + op3 + nums[3] + "=7";
                        break;
                    }
                }
            }
        }

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  int a[N];
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  int j=0;
  int b=1;
  for(int i=0;i<N+1;i++){
    if(b==2){
      break;
    }
    b=a[b-1];
    j++;
  }
  int c;
  if(j<=N)
    c=j;
  else
    c=-1;
  cout<<c<<endl;
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int X,Y,Z;
	scanf(" %d %d %d", &X, &Y, &Z);
	printf("%d\n",(X - Z) / (Z + Y));
	return 0;
}

Measured memory_bytes: 256
import sys
import math

def func(s):
    return int(s)-1


N=int(input())
e=[list(map(func,input().split()))+[i] for i in range(N-1)]
e.sort()

x=[0 for i in range(N)]
for i in range(N-1):
    x[e[i][0]]+=1
    x[e[i][1]]+=1
print(max(x))

e2=[[0 for j in range(x[i])]for i in range(N)]
ans=[0 for i in range(N-1)]

y=[0 for i in range(N)]

for i in range(N-1):
    [p,q,r]=e[i]

    e2[p][y[p]]=1
    if y[p]<x[q]: e2[q][y[p]]=1
    ans[r]=y[p]

    for j in range(y[p],x[p]):
        if e2[p][j]==0:
            y[p]=j
            break
    for j in range(y[q],x[q]):
        if e2[q][j]==0:
            y[q]=j
            break

for i in range(N-1):
    print(ans[i]+1)



Measured memory_bytes: 38408
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N; i >= 0; i--)
#define PI 3.1415926535

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;}

char upper(char c){
    if('a' <= c && c <= 'z'){
        c = c - ('a' - 'A');
    }
    return c;
}

char lower(char c){
    if('A' <= c && c <= 'Z'){
        c = c + ('a' - 'A');
    }
    return c;
}

const ll INF = 1000000000000000000;

//input



//processing



//dpTable
//int dp[100050];

int main(){
    int A,B,C,D,E;
    cin >> A >> B >> C >> D >> E;
    if (A == 0) cout << 1 << endl;
    if (B == 0) cout << 2 << endl;
    if (C == 0) cout << 3 << endl;
    if (D == 0) cout << 4 << endl;
    if (E == 0) cout << 5 << endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>
#include <functional>

using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

int main() {
	int N;
	cin >> N;
	cout << "ABC" << N << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  int a,b;
  cin>>a>>b;
  int c=a;
  if(a>b)c--;
  cout<<c;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
/*
**
Success doesn't come to you ,
You Go To IT .
**
*/
using namespace std;
#define all(v)          ((v).begin()), ((v).end())
#define finish(x) return cout << x << endl, 0;
#define pb push_back
#define Compiler_Beso ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define clr(v,d)        memset(v, d, sizeof(v))
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;


ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }


enum dir       { DOWN = 0, UP, RIGHT, LEFT, DOWN_RIGHT, DOWN_LEFT, UP_RIGHT, UP_LEFT };
int  dir_r[] = { 1, -1, 0, 0, 1, 1, -1, -1 };
int  dir_c[] = { 0, 0, 1, -1, 1, -1, 1, -1 };


int main()
{
	Compiler_Beso


		int n, r, c, ans = 0;
	cin >> n >> r >> c;
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= n; j++){
			if (n - i + 1 >= r && n - j + 1 >= c)++ans;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define inf 9999999999999999
#define F first
#define S second
#define eb emplace_back
#define mpp make_pair
#define P(x) cout<<__LINE__ <<": "<<#x<<' '<<(x)<<'\n'
#define dbg cout<<__LINE__ <<": 0manush\n"
#define read(x) freopen("input.txt","r",stdin)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pi 2*acos(0.0)
#define ee exp(1)
#define mx 100009
#define mod 10000007
using namespace std;
ll dp[mx];
int main(){//read(x);
//fast;
ll r,g,h,i,j,x,t,y,z=0,e,f,a,b,c,d,n,l,k;

    cin>>n;
    ll m[n];
    for(i=0;i<n;i++)cin>>m[i];
    dp[n-1]=0;
    dp[n-2]=abs(m[n-1]-m[n-2]);
    for(i=n-3;i>=0;i--){
        a=dp[i+1]+abs(m[i]-m[i+1]);
        b=dp[i+2]+abs(m[i]-m[i+2]);
        dp[i]=min(a,b);
    }
    //cout<<"Case "<<++z<<": ";
    cout<<dp[0]<<endl;

}




















Measured memory_bytes: 5204
#include <iostream>

using namespace std;

int main()
{
    char a, b, c, d;
    std::cin >> a >> b >> c >> d;
    std::cout << ((((a == b && c == d) || (a == c && b == d) || (a == d && b == c)) && !(a == b && a == c && a == d)) ? "Yes" : "No") << std::endl;
    return 0;
}

Measured memory_bytes: 256
input()

a = map(int, raw_input().split())
a.sort(reverse = True)

edge = []
p = 1
while p < len(a):
      if a[p] == a[p-1]:
              edge.append(a[p])
              p += 2
      else:
              p += 1

edge.append(0)
edge.append(0)
print edge[0] * edge[1]

Measured memory_bytes: 11320
N, Y = map(int, input().split())
Y = Y//1000

def solve(N, Y):
    for i in range(N+1):
        for j in range(N+1-i):
            res = 10*i + 5*j + (N-i-j)
            if res == Y:
                return i, j, N-i-j
    else:
        return -1, -1, -1

ans = solve(N, Y) 
print(*ans)

Measured memory_bytes: 9124
/*
* Author: Anmol Choudhary
*/
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int ll
//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(long 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 << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1e9+7;
const ll maxn = 1000005;
const ll mm = 1e+18;
void solve()
{
	int arr[3];
    rep0(i,3) cin>>arr[i];
    swap(arr[0],arr[1]);
    swap(arr[0],arr[2]);
    rep0(i,3) cout<<arr[i]<<" ";
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        //nx;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	vector<pair<int, int> > v;
	set<int> p;
	p.insert(0);
	p.insert(n + 1);
	for(int i = 1; i <= n; i++){
		int x; cin >> x;
		v.push_back({x, i});
		p.insert(i);
	}
	sort(v.begin(), v.end());
	long long ans = 0;
	for(int i = 0; i < n; i++){
		int w = v[i].second;
		{
			auto it = p.lower_bound(w);
			auto pv = it; pv--;
			if(pv != p.begin()){
				auto nv = pv; nv--;
				int delta = *pv - *nv;
				auto to = it; to++;
				int upmv = *to - w;
				ans += 1ll * delta * upmv * (i + 1);
			}
		}
		{
			auto it = p.lower_bound(w);
			auto pv = it; pv++;
			if((*pv) != n + 1){
				auto nv = pv; nv++;
				int delta = *nv - *pv;
				auto to = it; to--;
				int upmv = w - *to;
				ans += 1ll * delta * upmv * (i + 1);
			}
		}
		p.erase(w);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5748
#include<iostream>

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

//[cnt][sum]
int dp[16][256];
const int INF = 1e8;

int main(void){
  int to, c, s;
  while(1){
    cin >> to >> c >> s;
    if(to == 0)break;
    rep(i,16)rep(j,256)dp[i][j] = 0;
    dp[0][0] = 1;
    reps(i,1,to){
      for(int j = c-1; j >= 0; --j){
        reps(k,0,s){
          if(dp[j][k] != 0 && k + i <= s){
            dp[j+1][k + i] += dp[j][k];
          }
        }
      }
    }
    cout << dp[c][s] << endl;
  }
  return 0;
}

Measured memory_bytes: 1176
N = int(input())
S = str(input())
Sarray = list(S)

white = 0 #にしなきゃ
black = 0 #にしなきゃ
for i in range(len(Sarray)):
    if Sarray[i] == '.':
        black += 1

a = [white + black]
for i in range(len(Sarray)):
    if Sarray[i] == '.':
        black -= 1
    else:
        white += 1
    a.append(white + black)
a.sort()
print(a[0])

Measured memory_bytes: 13568
W, H, N = [int(_) for _ in input().split()]
xya = [[int(_) for _ in input().split()] for i in range(N)]

d = [[0], [W], [0], [H]]

for x, y, a in xya:
    if a == 1 or a == 2:
        d[a-1] += [x]
    else:
        d[a-1] += [y]

if min(d[1]) - max(d[0]) > 0 and min(d[3]) - max(d[2]) > 0:
    ret = (min(d[1]) - max(d[0])) * ( min(d[3]) - max(d[2]))
    print(max(ret, 0))
else:
    print(0)

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

public class Main {
    public static void main(String[] args) throws Exception{
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter output = new PrintWriter(System.out);
        int N = Integer.parseInt(input.readLine());
        StringTokenizer st = new StringTokenizer(input.readLine());
        int[] arr = new int[N];
        int[] dp = new int[N+1];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[0] = 0;
        for(int i = 0; i<N; i++){
            arr[i] = Integer.parseInt(st.nextToken());
        }
        for(int i = 0; i<N; i++){
            if(i+1<N) dp[i+1] = Math.min(dp[i+1], dp[i] + Math.abs(arr[i] - arr[i+1]));
            if(i+2<N) dp[i+2] = Math.min(dp[i+2], dp[i] + Math.abs(arr[i] - arr[i+2]));
        }
        output.println(dp[N-1]);

        /*boolean[] visited = new boolean[N];
        for(int i = 0; i<N; i++){
            arr[i] = Integer.parseInt(st.nextToken());
        }
        PriorityQueue<Node> pq = new PriorityQueue<Node>();
        pq.add(new Node(1, Math.abs(arr[0] - arr[1])));
        if(N>2)
            pq.add(new Node(2, Math.abs(arr[0] - arr[2])));

        while(!pq.isEmpty()){
            Node n = pq.poll();
            if(visited[n.i]) continue;
            visited[n.i] = true;
            if(n.i == N-1){
                output.println(n.d);
                break;
            }
            if(n.i<N-1)
                pq.add(new Node(n.i+1, n.d + Math.abs(arr[n.i] - arr[n.i+1])));
            if(n.i<N-2)
                pq.add(new Node(n.i+2, n.d + Math.abs(arr[n.i] - arr[n.i+2])));
        }
        */
        output.close();
    }
}

Measured memory_bytes: 32264
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) ((int)(x).size())
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N,X; cin>>N>>X;
    int g=0;
    REP(i,N){
        int x; cin>>x;
        g=__gcd(g,abs(x-X));
    }
    cout<<g<<endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
# A = [ int(input()) for _ in range(N) ]
##############################

import heapq

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

if N == 1:
    A[0] //= (2**M)
    print(A[0])
    exit()

hq = []
for a in A:
    heapq.heappush(hq, -a)

while M > 0:
    high = -1 * heapq.heappop(hq)
    high //= 2
    M -= 1
    heapq.heappush(hq, -high)

ans = 0
for i in range(N):
    ans += heapq.heappop(hq)

print(-ans)


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

int main(void){
    int N, K, max, tmp;
    int* p;

    scanf("%d %d",&N, &K);

    p=(int*)malloc(N*sizeof(int));

    for(int i=0; i<N; i++){
        scanf("%d",p+i);
    }

    for(int i=1; i<N; i++){
        p[i]=p[i]+p[i-1];
    }
    max=p[K-1];
    for(int i=1; i<N-K+1; i++){
        tmp=p[i+K-1]-p[i-1];
        if(max<tmp)
            max=tmp;
    }
    printf("%f",(max+K)/2.);


    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(std::string S)
{
    if(S.size() == 1){
        cout << 1 << endl;
        return;
    }
    int ans = 1;
    string prev = "";
    string now = "";
    prev += S[0];
    for (int i = 1; i < S.size(); i++)
    {
        now += S.substr(i, 1);
        if (prev == now)
        {
            continue;
        }
        else
        {
            ans++;
            prev = now;
            now = "";
        }
    }

    cout << ans << endl;
}

int main()
{
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


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

int main() {
  int N,Y;
  cin >> N >> Y;
  
  int x=-1,y=-1,z=-1;
  bool can = false;
  
  for(int i=0;i<=N;i++){
    for(int j=0;j<=N;j++){
      int k = N-i-j;  
      if(10000*i+5000*j+1000*k==Y && k>=0){
        x=i;
        y=j;
        z=k;
        can=true;
      }
      if(can==true){
        break;
      }
    }
    if(can==true){
      break;
    }
  }
  
  cout << x << ' ' << y << ' ' << z << endl;
  return 0;
  
}

Measured memory_bytes: 3612
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

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

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

struct mint {
    ll x;  // typedef long long ll;
    mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}

    mint operator-() const { return mint(-x); }

    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }

    mint& operator-=(const mint a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }

    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }

    mint operator+(const mint a) const { return mint(*this) += a; }

    mint operator-(const mint a) const { return mint(*this) -= a; }

    mint operator*(const mint a) const { return mint(*this) *= a; }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(MOD - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

int main() {
    INIT;

    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    mint ans = 0;
    mint two_factor = 1;

    rep(d, 60) {
        mint even = 0, odd = 0;
        rep(i, N) {
            if (A[i] & (1LL << d)) {
                odd += 1;
            } else {
                even += 1;
            }
        }

        mint now = odd * even * two_factor;
        two_factor *= 2;
        ans += now;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5548
N = int(input())
A = list(map(int, input().split()))
count = 0
for a in A:
    if a < 0:
        count += 1
    elif a == 0:
        count = 0
        break
A = list(map(abs, A))
A.sort()
if count % 2 == 0:
    print(sum(A))
else:
    print(sum(A[1:]) - A[0])


Measured memory_bytes: 14224
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
//#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
const int INF = 1<<29;
//const int MODINF = 1000000007;
using namespace std;


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

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

int main() {
  int N, K;
  cin >> N >> K;
  
  int min = 1;
  for (int i = 0; i < N; i++) {
    if (min + K < min * 2)
      min += K;
    else
      min *= 2;
  }
  
  cout << min << endl;
}

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

using namespace std;
typedef long long LL;
struct Edge{
    int dst;
    LL cost;
};

typedef vector<Edge> Node;
typedef vector<Node> Graph;
typedef pair<LL, int> P;

int main(){
    int N, M, X;
    while(cin >> N >> M >> X) {
        vector<LL> H(N);
        REP(i, N) cin >> H[i];

        Graph G(N);
        REP(i, M) {
            int a, b;
            LL c;
            cin >> a >> b >> c;
            a--; b--;
            if(H[a] - c >= 0) G[a].push_back({b, c});
            if(H[b] - c >= 0) G[b].push_back({a, c});
        }

        vector<LL> min_d(N);
        REP(i, N) min_d[i] = X - H[i];

        vector<LL> dist(N, LLONG_MAX);
        dist[0] = 0;
        priority_queue<P, vector<P>, greater<P>> que;
        que.push({0, 0});
        while(!que.empty()){
            auto p = que.top(); que.pop();
            int u = p.second;
            LL c = p.first;
            if(dist[u] < c) continue;

            for(Edge e : G[u]) {
                int v = e.dst;
                LL nc = e.cost + c;
                if(min_d[v] > nc) nc = min_d[v];
                if(dist[v] <= nc) continue;
                dist[v] = nc;
                que.push({nc, v});
            }
        }

        //REP(i, N) cout << dist[i] << " "; cout << endl;

        if(dist[N - 1] == LLONG_MAX) {
            cout << -1 << endl;
        } else {
            LL ans = dist[N - 1];
            ans += abs(H[N - 1] - (X - dist[N - 1]));

            cout << ans << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 19768
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
const ll Mod=1000000007;
const ll INF=999999999999999999;
const ll NN=(ll)(1e6+5);
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {
       ll n,i,x,y,c=0,d;
       cin>>n>>d;
       while(n--)
       {
           cin>>x>>y;
           if((x*x+y*y)<=d*d)
            c++;
       }
       cout<<c;
   }
}

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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main() {
    int n;
    string a,b,c;
    cin>>n>>a>>b>>c;

    int ans=0;
    rep(i,0,n){
        if(a[i]!=b[i]&&b[i]!=c[i]&&a[i]!=c[i])ans+=2;
        else if((a[i]==b[i]&&b[i]!=c[i]&&a[i]!=c[i])||
                (a[i]!=b[i]&&b[i]==c[i]&&a[i]!=c[i])||
                (a[i]!=b[i]&&b[i]!=c[i]&&a[i]==c[i]))ans+=1;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3644
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;

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

            string a = Console.ReadLine();
            string b = Console.ReadLine();
            string c = Console.ReadLine();

            int r = 0;
            for (int i = 0; i < n; i++)
            {
                bool ab = a[i] == b[i];
                bool bc = b[i] == c[i];
                bool ac = a[i] == c[i];

                if (ab && bc)
                {
                    continue;
                }
                if (ab || bc || ac)
                {
                    r++;
                    continue;
                }
                r += 2;
            }

            Console.WriteLine(r);
            Console.ReadLine();
        }
    }

}


Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;

using namespace std;

int main() {
    ll N;
    cin >> N;
    map<pair<ll,ll>,ll> color = map<pair<ll,ll>,ll>();
    vector<pair<ll,ll>> E(N - 1);
    vector<pair<vector<ll>,ll>> G(N);//辺集合とparent
    for(int i = 0; i < N; i++){
        G[i].first = vector<ll>(0);
        G[i].second = -1;
    }
    for(int i = 0; i < N - 1; i++){
        ll a,b;
        cin >> a >> b;
        E[i] = pair<ll,ll>(a - 1,b - 1);
        color[make_pair(a-1,b-1)] = -1;
        color[make_pair(b-1,a-1)] = -1;
        G[a-1].first.push_back(b - 1);
        G[b-1].first.push_back(a - 1);
    }
    bool didVisit[N];
    for(int i = 0; i < N; i++){
        didVisit[i] = false;
    }
    queue<ll> q = queue<ll>();
    q.push(0);
    ll count = 0;
    while (q.size() > 0){
        ll thisV = q.front();q.pop();
        count = max(count,(ll)G[thisV].first.size());
        ll col = 1;
        for(int i = 0; i < G[thisV].first.size(); i++){
            ll a = G[thisV].second;
            ll b = G[thisV].first[i];
            if(didVisit[b]){
                continue;
            }
            if(a != -1 &&  color[make_pair(a,thisV)] == col){
                col++;
            }
            color[make_pair(thisV,b)] = col;
            color[make_pair(b,thisV)] = col;
            G[b].second = thisV;
            q.push(b);
            col++;
        }
        didVisit[thisV] = true;

    }
    cout << count << endl;
    for(int i = 0; i < N - 1; i++){
        cout << color[E[i]] << endl;
    }



}

Measured memory_bytes: 21632
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>

using namespace std;

typedef long long ll;

#define forn(i, n) for(int i = 0; i < int(n);++i)
#define pb push_back
#define vi vector<int>
#define pll pair<ll,ll>
#define pvii pair<vi,int>
#define vb vector<bool>
#define vvi vector<vi>
#define vpll vector<pll>
#define vll vector<ll>
#define vvll vector<vll>
#define sz(x) (int)x.size()
#define ff first
#define ss second

void solve() {

}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin >> n;
    string s;
    map<string, int> ennui;
    forn(i, n) {
        cin >> s;
        sort(s.begin(),s.end());
        ennui[s]++;
    }
    ll ans = 0;
    for(auto i: ennui){
        for(int j = 1; j <= i.ss - 1; ++j){
            ans += j;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 11264
#include <bits/stdc++.h>
#include<math.h>
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main() {
  long x;
  cin>>x; 
    if(x%11==0){
      cout<<2*(x/11)<<endl;
    }else if(x%11<=6){
      cout<<2*(x/11)+1<<endl;
    }else{
      cout<<2*(x/11)+2<<endl;
    }
 
  
 
}









Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{	int n,i,j=0;
	double g;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		if(i%2==1)
		j++;
	}
	g=n;
	printf("%.10lf",j/g);
	return 0;	
		
 } 

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }

int main(){
    ll H, W;
    cin >> H >> W;
    vector<vector<bool>> s;
    REP(h, H) {
        vector<bool> b(W);
        s.push_back(b);
        REP(w, W) {
            char c;
            cin >> c;
            if (c == '#') s[h][w] = true;
            else s[h][w] = false;
        }
    }
    
    REP(h, H-1){
        REP(w, W-1){
            bool p = s[h][w];
            if (!p) continue;
            else {
                bool b = s[h+1][w];
                bool r = s[h][w+1];
                if (p==b) continue;
                else if (p==r) continue;
                if (h>0) {
                    bool t = s[h-1][w];
                    if (p==t) continue;
                }
                if (w>0) {
                    bool l = s[h][w-1];
                    if (p==l) continue;
                }
                cout << "No\n";
                return 0;
            }
        }
    }
    cout << "Yes\n";
}


Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))

isYes = True
for i in reversed(range(N)):
    if i == 0:
        break
    if H[i-1] > H[i]:
        H[i-1] -= 1
        if H[i-1] > H[i]:
            print("No")
            isYes = False
            break
if isYes:
    print("Yes")

Measured memory_bytes: 14396
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <tuple>
#include <complex>
#include <cassert>
#include <exception>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define sz size()
#define endl "\n"
#define print(X) cout << (X) << "\n"
#define input(X) getline(cin,X)
static const int INF = 1e+9+7;
static const ll INFL = 1e+18+7;
ll n,m,l;
int p;
string s,t;
ll d[200010],dp[300][300];
char field[200][200];

int extgcd(int a,int b,int &x,int &y){
  int p = a;
  if(b != 0){
    p = extgcd(b,a % b,y,x);
    y -= (a/b) * x;
  }else{
    x = 1;y = 0;
  }
  return p;
}

int gcd(int x,int y){
  if(y == 0)return x;
  return gcd(y,x % y);
}

int main(){
  while(cin >> n >> m >> l,(n+m+l)){
    int g = gcd(n,m);
    n /= g,m /= g,l /= g;
    int x,y;
    extgcd(n,m,x,y);
    x *= l,y *= l;
    int ans_x = abs(x),ans_y = abs(y);
    // cout << "ans:" << ans_x << " " << ans_y << endl;
    lep(i,-5e+4,5e+4){
      int p = abs(x + m * i),q = abs(y - n * i);
      if(ans_x + ans_y > p + q || (ans_x + ans_y == p + q && n * ans_x + m * ans_y > n * p + m * q)){
        ans_x = p,ans_y = q;
      }
    }
    cout << ans_x << " " << ans_y << endl;
  }
  return 0;
}


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

int64_t calcGCD(int64_t a, int64_t b)
{
	while (a)
	{
		b %= a;
		std::swap(a, b);
	}
	return b;
}

bool match(int, int);

int main()
{
	int N;
	scanf("%d", &N);
	std::vector<int> ans;
	const int quo{N / 8}, rem{N % 8};
	for (int i{}; i < quo; i++)
		for (int j{1}; j <= 12; j++)
			if (j % 2 == 0 || j % 3 == 0)
				ans.push_back(12 * i + j);
	
	if (rem == 1)
		ans.push_back(12 * quo + 6);
	else if (rem == 2)
	{
		ans.push_back(12 * quo + 4);
		ans.push_back(12 * quo + 8);
	}
	else if (rem == 3)
	{
		std::vector<int> add{3, 6, 9};
		if (N == 3)
			add = {2, 5, 63};
		for (auto& e: add)
			ans.push_back(12 * quo + e);
	}
	else
	{
		for (int set{}; set < (1 << 12); set++)
		{
			if (!match(set, rem)) continue;
			for (int i{}; i < 12; i++)
			{
				if (~set >> i & 1) continue;
				ans.push_back(quo * 12 + i + 1);
			}
			break;
		}
	}
	for (int i{}; i < N; i++)
		printf("%d%c", ans[i], i + 1 == N? '\n': ' ');

	return 0;
}

bool match(int set, int remainder)
{
	for (int i{}; i < 12; i++)
		if ((set >> i & 1) && (i + 1) % 3 != 0 && (i + 1) % 2 != 0)
			return false;
	int count{};
	for (int i{}; i < 12; i++)
		if (set >> i & 1)
			count++;
	if (count != remainder)
		return false;
	int sum{};
	for (int i{}; i < 12; i++)
		if (set >> i & 1)
			sum += i + 1;
	if (sum % 6 != 0) return false;
	int64_t gcd{};
	for (int i{}; i < 12; i++)
		if (set >> i & 1)
			gcd = calcGCD(gcd, i + 1);
	return gcd == 1;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ctime>
#include <cstdlib>
#define rep(i, N) for (int i = 0; i < (N); i++)
#define swap(a, b) (a += b, b = a - b, a -= b)
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<int> v(N);
    rep(i, N)
    {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    double ave = 0;
    ave = v[0];
    rep(i, N - 1)
    {
        ave += v[i + 1];
        ave *= 0.5;
    }
    cout << ave << endl;
}

Measured memory_bytes: 256
#pragma comment (linker, "/STACK:256000000")
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define sz(c) (int)(c.size())
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
template<class T, class U>using vp = vector<pair<T, U>>;
template<class T>using vv = vector<vector<T>>; template<class T, class U>using vvp = vv<pair<T, U>>;
template<class T>vv<T> vvec(const size_t n, const size_t m, const T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; }return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; }return 0; }
constexpr ll pow2(const int n) { return 1ll << n; }
constexpr int INF = 1 << 28; constexpr ll LINF = 1ll << 60;
constexpr int MAX = 1e5 + 5; constexpr int MOD = 1e9 + 7; constexpr double EPS = 1e-6;
constexpr int dy[4] = { 0,1,0,-1 }; constexpr int dx[4] = { 1,0,-1,0 };
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;
// 1. 問題よくよめえええええええええええええええええええええええええ
// 2. intオーバーフロー << * + あたり
// 3. 落ち着け

int N, M, H, W;
int ans;
string s;

bool isATGC(const char c) {
    return c == 'A' || c == 'T' || c == 'G' || c == 'C';
}

int main() {
    cin >> s;

    int ans = 0;
    for (int i = 0; i < s.size(); ++i) {
        if (not isATGC(s[i])) continue;

        int j = i;
        for (; j < s.size(); ++j) {
            if (not isATGC(s[j])) break;
        }

        chmax(ans, j - i);
        i = j;
    }

    write(ans);
}

Measured memory_bytes: 256
h,w=map(int,input().split())
S = [["."]*(w+2)]
for i in range(h):
  S.append(["."]+list(input())+["."])
S.append(["."]*(w+2))
for i in range(h+2):
  for j in range(w+2):
    if S[i][j] == "#":
      if S[i+1][j] == "." and S[i-1][j] == "." and S[i][j+1] == "." and S[i][j-1] == ".": 
        print("No")
        quit()
print("Yes")

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

public class Main {
    void run() {
        String S = read();
        int L = 8;
        char[] ts = "AIDUNYAN".toCharArray();
        Arrays.sort(ts);
        for (int i = 0; i + L <= S.length(); ) {
            char[] cs = S.substring(i, i + L).toCharArray();
            Arrays.sort(cs);
            if (Arrays.equals(cs, ts)) {
                S = S.substring(0, i) + "AIZUNYAN" + S.substring(i + L);
                i += L;
            }
            else {
                i += 1;
            }
        }
        sysout.println(S);
    }

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

    // flush automatically iff you call `println` or `printf` or `format`.
    PrintWriter sysout = new PrintWriter(System.out, true);

    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer buffer = null;

    String readLine() {
        buffer = null;
        try {
            return in.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    String read() {
        if (buffer == null || !buffer.hasMoreTokens()) {
            buffer = new StringTokenizer(readLine());
        }
        return buffer.nextToken();
    }

    int readInt() {
        return Integer.parseInt(read());
    }

    long readLong() {
        return Long.parseLong(read());
    }

    double readDouble() {
        return Double.parseDouble(read());
    }
}

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

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 2e5 + 5;

typedef pair<int,int>   ii;

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

    ll  S;  cin >> S;
    ll  x = sqrt(S);

    if (x * x == S) {
        cout << "0 0\n";
        cout << "0 " << x << "\n";
        cout << x << " 0";
        return  0;
    }
    ++x;

    for(ll  a = x ; a <= min(1000000000ll,x + 1) ; ++a)
    for(ll  b = x ; b <= min(1000000000ll,x + 1) ; ++b)    {
        ll  R = a * b - S;
        ll  c = 1;
        ll  d = R;

        for(; c * c <= R ; ++c) if (R % c == 0) {
            d = R / c;
            if (d <= 1000000000)
                break;
        }
        if (d <= 1000000000)    {
            cout << "0 0\n";
            cout << a << " " << c << "\n";
            cout << d << " " << b << "\n";
            return  0;
        }
    }
}

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

L = [int(input()) for _ in range(N)]

ans = []
def dfs(idx, a, b, c, mp10):
    if idx==N:
        if a and b and c:
            ans.append(abs(A-a)+abs(B-b)+abs(C-c)+mp10*10)
    else:
        dfs(idx+1, a, b, c, mp10)
        dfs(idx+1, a+L[idx], b, c, mp10+1)
        dfs(idx+1, a, b+L[idx], c, mp10+1)
        dfs(idx+1, a, b, c+L[idx], mp10+1)

dfs(0, 0, 0, 0, -3)

print(min(ans))

Measured memory_bytes: 4980