akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

static int top;
static int S[101];

void push(int x)
{
    S[++top] = x;
}

int pop()
{
    top--;
    return S[top + 1];
}

int main()
{
    int a, b;
    top = 0;
    char s[100];

    while (scanf("%s", s) != EOF) {
        if (s[0] == '+') {
            a = pop();
            b = pop();
            push(a + b);
        } else if (s[0] == '-') {
            b = pop();
            a = pop();
            push(a - b);
        } else if (s[0] == '*') {
            a = pop();
            b = pop();
            push(a * b);
        } else {
            push(atoi(s));
        }
    }

    printf("%d\n", pop());
    return 0;
}


Measured memory_bytes: 2048
# C
h, w = map(int, input().split())
s = [list(str(input())) for i in range(h)]

can = True
for i in range(h-1):
    for j in range(w-1):
        if s[i][j] == '#':
            cnt = 0
            if j+1 < w and s[i][j+1] == '#':
                cnt += 1
            if j-1 >= 0 and s[i][j-1] == '#':
                cnt += 1
            if i+1 < h and s[i+1][j] == '#':
                cnt += 1
            if i-1 >= 0 and s[i-1][j] == '#':
                cnt += 1
            if cnt > 0:
                continue
            else:
                can = False
                break
    if not can:
        break
if can:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define fr(i,k,n) for(int i=k;i<n;i++)
#define read(x) cin>>x
#define ll long long int
#define mod 1000000007 
#define print(x) cout<<x<<endl
#define pb(x) push_back(x)
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  
int main() { 
    fastIO;
     int t=1,n ;
     //cin>>t;
     while(t--){
         cin>>n ;
       vector<int>a(n );
       vector<vector<ll>>dp(n,vector<ll>(n,0));
      // int x=0,y=0;
       fr(i,0,n ){ 
       cin>>a[i];
        
       }
       
       for(int l=n-1;l>=0;l--) 
         for(int r=l;r<n;r++){
           if(l==r)
             dp[l][r]=a[l];
           else
           {dp[l][r]=max(-dp[l+1][r]+a[l],-dp[l][r-1]+a[r]);
              
           }
          
        }
      cout<<dp[0][n-1]<<endl;}
	return 0;
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
int main() {
	int N;
	string s;
	int ans = 0;
	cin >> N >> s;
	for (int i = 2; i < N; i++) {
		if (s[i - 2] == 'A' && s[i - 1] == 'B' && s[i] == 'C') {
			ans++;
		}
	}
	cout << ans << endl;
}

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

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

    vector<int> v;
    bool zero;

    if(s[0]=='0') zero=true;
    else zero=false;
    vector<int> sum;
    int cnt=1;
    for(int i=1;i<n;i++){
        if(s[i]==s[i-1]){
            cnt++;
        }
        else{
            v.push_back(cnt);
            cnt=1;
        }
    }
    v.push_back(cnt);
    int ans=0;
    int c=0;
    sum.push_back(0);
    for(auto i:v){
        sum.push_back(c+i);
        c+=i;
    }
    sum.push_back(n-1);
    if(zero){
        if((v.size()+1)/2 <= k){
            cout<<n<<endl;
            return 0;
        }
        int ret=0;
        for(int i=0;i<k*2;i++) ret+=v[i];
        ans=max(ret,ans);

        for(int i=1;i+k*2+1<sum.size();i+=2){
            ret=sum[i+k*2+1]-sum[i];
            ans=max(ret,ans);
        }
        if(v.size()%2==1){
            ans=max(ans,n-sum[v.size()-k*2]);
        }
        else {
            ans=max(ans,n-sum[v.size()-1-k*2]);
        }
    }
    else {
        if(v.size()/2 <= k){
            cout<<n<<endl;
            return 0;
        }
        int ret=0;
        for(int i=0;i<=k*2;i++) ret+=v[i];
        ans=max(ret,ans);

        for(int i=2;i+k*2+1<sum.size();i+=2){
            ret=sum[i+k*2+1]-sum[i];
            ans=max(ret,ans);
            cerr<<ans<<" "<<sum[i+k*2+1]<<" "<<sum[i]<<endl;
        }
        if(v.size()%2==0){
            ans=max(ans,n-sum[v.size()-k*2]);
        }
        else {
            ans=max(ans,n-sum[v.size()-1-k*2]);
        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 1528
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)
ans = a[0]
if n % 2 == 0:
    ans += 2 * sum(a[1 : n // 2])
else:
    ans += 2 * sum(a[1 : (n - 1) // 2])
    ans += a[(n - 1) // 2]
print(ans)

Measured memory_bytes: 31592
#include <bits/stdc++.h> 
#define ll long long int
#define pb push_back

using namespace std; 


int main() 
{
    int a,b,c;
    cin>>a>>b>>c;
    
    if(a+b+c >= 22) cout<<"bust"<<endl;
    else cout<<"win"<<endl;
}

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

int main() {
	int H, W, D;
	cin >> H >> W >> D;
	vector<pair<int, int>>data(H*W);
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			int num;
			cin >> num;
			data[num] = make_pair(i, j);
		}
	}
	//前処理、累積和
	vector<int>sum(H*W + 1);
	for (int i = 1; i <= H * W; ++i) {
		if (i <= D) {
			sum[i] = 0;
		}
		else {
			int j = i - D;
			sum[i] = sum[i - D] + abs(data[j].first - data[i].first) + abs(data[j].second - data[i].second);
		}
	}

	int Q;
	cin >> Q;
	for (int i = 0; i < Q; ++i) {
		int L, R;
		cin >> L >> R;
		cout << sum[R] - sum[L] << endl;
	}
	return 0;
}


Measured memory_bytes: 4232
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
const int MOD = 1e9 + 9, N = 101;
ll wi[N], v[N];
ll dp[102][100005];

ll go(ll idx, ll weight){
    if(idx == -1 || weight == 0)
        return 0;
    if(dp[idx][weight] != -1) return dp[idx][weight];
    ll ans = go(idx - 1, weight);
    if(wi[idx] <= weight)
        ans = max(ans, go(idx - 1, weight - wi[idx]) + v[idx]);
    return dp[idx][weight] = ans;
}


int main(){
    ll n, w;
    cin >> n >> w;
    for(int i = 0; i < n; ++i)
        cin >> wi[i] >> v[i];
    memset(dp, -1, sizeof dp);
    cout << go(n-1, w);
    return 0;
}

Measured memory_bytes: 80000
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define speedX ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
#define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout<< name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_time() cout << "\n\nTime of execution: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define trace(...)
#define end_time()
#endif


#define int long long 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
inline bool equals(ld a, ld b) {return fabs(a - b) < 1e-9;}
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define uset unordered_set
#define umap unordered_map
#define all(x) x.begin(), x.end()
#define mod 1000000007


void solve(){
	int n;
	cin>>n;
	int arr[n];
	for(int i = 0; i<n; i++){
		cin>>arr[i];
	}
	int tmp = 1;
	int ans = 0;
	for(int i = 0; i<n; i++){
		if(arr[i]==tmp) tmp++;
		else ans++;
	}
	if(ans==n) cout<<"-1";
	else cout<<ans;
}
signed main(){
	speedX;
	#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	end_time();
	return 0;
}

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

int main(){
  string S;
  cin>>S;
  bool flag1=false;
  bool flag2=false;
  bool flag3_=false;
  
  if (S[0]=='A'){
    flag1=true;
    S.erase(0,1);
  }
  int count=0;
  int x;
  for (int i=1; i<S.size()-1; i++){
    if (S[i]=='C'){
      count++;
      x=i;
    }
  }
  if (count==1){
    flag2=true;
  }
  if (flag2){
    S.erase(x,1);
  }
  
  for (int c : S){
    if (isupper(c)){
      flag3_=true;
    }
  }
  if (flag1*flag2*(!flag3_)){
    cout<<"AC"<<endl;
  }else{
    cout<<"WA"<<endl;
  }
}

Measured memory_bytes: 3608
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<math.h>
typedef long long LL;
int main() {
	int h = 0, w = 0;
	std::vector<std::string> graph = {};
	std::string str;
	std::cin >> h >> w;
	for (int i = 0; i < h; i++) {
		std::cin >> str;
		graph.push_back(str);
	}
	for (int i = 0; i < h; i++) {
		std::cout << graph[i] << std::endl;
		std::cout << graph[i] << std::endl;
	}
}

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

int main(){
  int n, a, x[51]={};
  cin >> n >> a;
  for(int i = 0; i < n; i++) {
    cin >> x[i];
  }
  ll dp[50+1][50+1][50*50+1]={};
  dp[0][0][0] = 1;
  for(int i = 1; i <= n; i++) {
    for(int j = 0; j <= n; j++) {
      for(int k = 0; k <= 50*n; k++) {
        dp[i][j][k] = dp[i-1][j][k] + (k >= x[i-1] && j >= 1?dp[i-1][j-1][k-x[i-1]]:0);
      }
    }
  }
  ll ans = 0;
  for(int i = 1; i <= n; i++) {
    ans += dp[n][i][i*a];
  }
  cout << ans << endl;
}

Measured memory_bytes: 51072
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#define pi 3.141592653589
#include<iomanip>
using namespace std;
#include<algorithm>



int main(){
    
    double x;
    
    cin>>x;
    x=(-1+sqrt(1+8*x))/2;
    cout<<ceil(x)<<endl;
    
    return 0;
}
 

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


int main(){
  int a[4],b[4];

  for(int i=0;i<4;i++){
    cin>>a[i]>>b[i];
    if(a[i]==1){b[i]=b[i]*6000;}
    if(a[i]==2){b[i]=b[i]*4000;}
    if(a[i]==3){b[i]=b[i]*3000;}
    if(a[i]==4){b[i]=b[i]*2000;}
  }

  for(int i=0;i<4;i++){
    cout<<b[i]<<endl;
  }


  
  return 0;
}



Measured memory_bytes: 3080
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int a;

void init() {
	scanf("%d", &a);
	return ;
}

void solve() {
	int p = a;
	for(register int i = 9; i >= 2; i--) {
		if(p % i == 0) {
			p /= i;
			break;
		}
	}
	if(1 <= p && p <= 9) printf("Yes\n");
	else printf("No\n");
	return ;
}

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

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N, A, B;

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

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

class Program
{
	public static void Main(string[] args)
	{
		var N = int.Parse(Console.ReadLine());
		var answer = new int[N];

		// 配列を初期化
		for (int i = 0; i < N; i++)
		{
			answer[i] = 100000;
		}

		// スペース区切りの整数の入力
		var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

		// Startは0
		answer[0] = 0;
		// 二番目のコスト。
		answer[1] = Math.Abs(input[1] - input[0]);

		for (int i = 2; i < N; i++)
		{
			var a = answer[i - 1] + Math.Abs(input[i] - input[i - 1]);
			var b = answer[i - 2] + Math.Abs(input[i] - input[i - 2]);

			if (a > b)
				answer[i] = b;
			else
				answer[i] = a;
		}
		Console.WriteLine(answer[N - 1]);

	}

}



Measured memory_bytes: 18016
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <set>
#include <unordered_set>
#include <vector>
#include<valarray>
#include<map>
#include <bits/stdc++.h>
#include <utility>
#include<bits/stdc++.h>
using namespace std;

int main()
{
long long n,k;
cin>>n>>k;
long long a[n];
long long sum=0;
for(int i=0;i<n;i++)
{
    cin>>a[i];
}
sort(a,a+n);
for(int i=0;i<k;i++)
{
    sum+=a[i%n];


}
cout<<sum;
    return 0;
}

Measured memory_bytes: 3616
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,n) for(int i=(n)-1;i>=0;--i)
#define rrep2(i,a,b) for(int i=(a)-1;i>=b;--i)
// #define range(i,a,b,c) for(int i=a;\
c>0?i<b:\
i>b;\
i+=c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define all(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
// #define int ll
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif

int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 1 << 28;
const ll INFL = (ll)1 << 58;
ll mod = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real& r) { return (r > eps) - (r < -eps); }
int sgn(const Real& a, const Real &b) { return sgn(a - b); }

//.....................
const int MAX = (int)2e5 + 5;

vector<string> split(const string &str, char sep) {
	vector<string> v;
	stringstream ss(str);
	string buffer;
	while (getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}

int H, W;

bool ng(int y, int x) {
	return y < 0 || H <= y || x < 0 || W <= x;
}

ll n, m;
string s;

bool ok(string& state) {
	rep2(i, 1, n+1) {
		int a = (i + 1) % n;
		int b = (i + n - 1) % n;
		int c = i % n;
		if (s[c] == 'o' && state[c] == 'S'
			|| s[c] == 'x' && state[c] == 'W') {
			if (state[a] != state[b] && state[a] != ' ') {
				return false;
			}

			state[a] = state[b];
		}
		if (s[c] == 'o' && state[c] == 'W'
			|| s[c] == 'x' && state[c] == 'S') {
			if (state[b] == 'W') {
				if (state[a] == state[b] && state[a] != ' ') {
					return false;
				}

				state[a] = 'S';
			}
			if (state[b] == 'S') {
				if (state[a] == state[b] && state[a] != ' ') {
					return false;
				}

				state[a] = 'W';
			}
		}
	}
	return true;
}

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

	string res;
	rep(i, 2) rep(j, 2) {
		string state;
		rep(k, n) state.push_back(' ');

		state[0] = (i == 0 ? 'S' : 'W');
		state[1] = (j == 0 ? 'S' : 'W');
		if (ok(state)) {
			cerr << state << endl;
			res = state;
		}
	}
	cerr << endl;
	if (res != "") cout << res << endl;
	else cout << -1 << endl;
}

























signed main() {
	int T = 100;
	cout << fixed << setprecision(15);
	rep(i, T) {
		char s[MAX];
		if (scanf("%s", s) == EOF) break;
		int n = strlen(s);
		for (int i = n - 1; i > -1; i--) {
			ungetc(s[i], stdin);
		}
		solve();
	}
	return 0;
}

Measured memory_bytes: 716
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    lint ans,k,a,b;cin>>k>>a>>b;
    if(b-a>2){
        if(a-1>=k){
            ans=k+1;
        }
        else{
            k-=(a-1);
            ans=a;
            if(k%2==1){ans++;k--;}
            ans+=(b-a)*(k/2);
        }
    }
    else{
        ans=k+1;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;

ll n;
ll a[100005];
ll b[100005];
ll c[100005];
queue<ll> qu;
vector<ll> ve[100005];

int main()
{
    scanf("%lld", &n);
    for(ll i = 2; i <= n; i++)
    {
        scanf("%lld", &a[i]);
        b[a[i]]++;
    }
    for(ll i = 1; i <= n; i++)
    {
        if(b[i] == 0)
        {
            qu.push(i);
        }
    }
    while(!qu.empty())
    {
        ll t = qu.front();
        qu.pop();
        ll mx = 0;
        if(ve[t].size() == 0) c[t] = 0;
        else
        {
            sort(ve[t].begin(), ve[t].end(), greater<ll>());
            for(ll i = 0; i < ve[t].size(); i++)
            {
                mx = max(mx, ve[t][i] + i + 1);
            }
            c[t] = mx;
        }
        b[a[t]]--;
        ve[a[t]].push_back(c[t]);
        if(b[a[t]] == 0) qu.push(a[t]);
        if(t == 1)
        {
            printf("%lld", c[1]);
            return 0;
        }
    }
    return 0;
}


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

int main() {
    int N, M, X, Y, x, y;
    cin >> N >> M >> X >> Y;
    int max_x = -1e9, min_y = 1e9;
    for (int i = 0; i < N;i++)
    {
        cin >> x;
        max_x = max(max_x, x);

    }
    max_x = max(max_x, X);
    for (int i = 0; i < M;i++)
    {
        cin >> y;
        min_y = min(min_y, y);
    }
    min_y = min(min_y, Y);
    if (max_x < min_y)
    {
        cout << "No War";
        return 0;
    }
    cout << "War";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cctype>
#define _USE_MATH_DEFINES
#include <math.h>
#include <string>
#include <list>
using namespace std;

int n, m[100][100], d[100], p[100];

string color[100];

void dijkstra(){
  for(int i = 0; i < n; i++){
    color[i] = "white";
    d[i] = 10000000;
  }

  d[0] = 0;
  p[0] = -1;

  while(1){
    int mincost = 10000000, u;

    for(int i = 0; i < n; i++){
      if(color[i] != "black" && d[i] < mincost){
        mincost = d[i];
        u = i;
      }
    }
    if(mincost == 10000000) break;

    color[u] = "black";

    for(int v = 0; v < n; v++){
      if(color[v] != "black" && m[u][v] < 10000000){
        if(d[u] + m[u][v] < d[v]){
          d[v] = d[u] + m[u][v];
          p[v] = u;
          color[v] = "glay";
        }
      }
    }
  }
}


int main(){

  cin >> n;

  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      m[i][j] = 10000000;
    }
  }

  for(int i = 0; i < n; i++){
    int id, k, v, c;
    cin >> id >> k;
    for(int j = 0; j < k; j++){
      cin >> v >> c;
      m[id][v] = c;
    }
  }

  dijkstra();



  for(int i = 0; i < n; i++){
    cout << i << " " << d[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 3192
a = []
for _ in range(6):a.append(sorted(list(map(int, input().split()))))
a.sort(key = lambda x:x[1])
a.sort(key = lambda x:x[0])
print("yes" if a[0] == a[1] and a[2] == a[3] and a[4] == a[5] and a[0][0] == a[2][0] and a[0][1] == a[4][0] and a[2][1] == a[4][1] else "no")


Measured memory_bytes: 5604
#include<iostream>
#include<vector>
#include<algorithm>

typedef long long ll;

int main(){
	ll n;
	std::cin >> n;

	std::string ans;
	while(n>0){
		n--;
		ans.push_back('a' + n%26);
		n /= 26;
	}
	std::reverse(ans.begin(), ans.end());
	std::cout << ans << std::endl;
	return 0;
}

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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

typedef pair<int, int> ii;

int n, a[(1 << 18)], ans;

ii dp[(1 << 18)];

bool checkBit(int mask, int pos){
    if((mask & (1 << pos)))
        return 1;
    else
        return 0;
}

int main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> n;
    for(int i = 0; i < (1 << n); i++){
        cin >> a[i];
        dp[i].fi = a[i];
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < (1 << n); j++){
            if(checkBit(j, i)){
                dp[j].se = max(dp[j].se, dp[(j ^ (1 << i))].fi);
                if(dp[j].se > dp[j].fi)
                    swap(dp[j].se, dp[j].fi);
            }
        }
    }
    for(int i = 1; i < (1 << n); i++){
        ans = max(ans, dp[i].se + dp[i].fi);
        cout << ans << "\n";
    }
}


Measured memory_bytes: 6144
n,k = map(int,input().split())
x = list(map(int,input().split()))
ans = float("Inf")

for i in range(n-k+1):
    if x[i]*x[i+k-1] < 0:
        ans = min(ans, abs(x[i]) + abs(x[i+k-1]) +min(abs(x[i]), abs(x[i+k-1])))
    else:
        ans = min(ans, max(abs(x[i]), abs(x[i+k-1])))
print(ans)

Measured memory_bytes: 20016
// Ver19.03
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF 1 << 29
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  ll n;
  char s;
  scanf("%lld", &n);
  for (int i = 0; i < n; i++)
  {
    scanf("%c", &s);
    if (s == 'Y')
    {
      puts("Four");
      return 0;
    }
  }
  puts("Three");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
const double EPS = 1e-9;
const int INF = 10000000;
const int MOD = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
typedef long long ll;
using namespace std;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	while(cin >> n, n)
	{
		vector<int> vec(n + 1), R(n + 1), O(n + 1);
		for(int i = 0; i < n; i++)
		{
			cin >> vec[i];
		}
		double H = 1e9;
		int ans1, ans2, ans3;
		for(int s = 0; s < 16; s++)
		{
			for(int a = 0; a < 16; a++)
			{
				for(int c = 0; c < 16; c++)
				{
					vector<int> cnt(256, 0);
					R[0] = s;
					for(int i = 1; i <= n; i++)
					{
						R[i] = (a * R[i - 1] + c) % 256;
						O[i] = (vec[i - 1] + R[i]) % 256;
						cnt[O[i]]++;
					}
					double sum = 0;
					for(int i = 0; i < 256; i++)
					{
						if(cnt[i] <= 0)
							continue;
						sum -= (((double)cnt[i] / n) * log((double)cnt[i] / n));
					}
					if(sum + EPS < H)
					{
						H = sum;
						ans1 = s;
						ans2 = a;
						ans3 = c;
					}
				}
			}
		}
		cout << ans1 << " " << ans2 << " " << ans3 << endl;
	}
	return 0;
}




Measured memory_bytes: 3476
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <utility>
#define mp make_pair

using namespace std;
const int inf = 0x3f3f3f3f;
const int neginf = 0xc0c0c0c0;
typedef long long ll;
typedef pair<int,int> P;

int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	if(a % 2 && b % 2) puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,m;
struct City
{
	int y,p;
	int ID;
	int name;
}a[100010];
int cnt[100010];
bool cmp(const City &x,const City &y)
{
	return x.y<y.y;
}
bool cmp1(const City &x,const City &y)
{
	return x.name<y.name;
}
int main()
{
	ios::sync_with_stdio(false);
	cin>>m>>n;
	for(int i=1;i<=n;i++)
	  cin>>a[i].p>>a[i].y,a[i].name=i;
	sort(a+1,a+1+n,cmp);  
	for(int i=1;i<=n;i++)
	  {
	  	++cnt[a[i].p];
	  	a[i].ID=cnt[a[i].p];
	  }
	sort(a+1,a+1+n,cmp1);
	for(int i=1;i<=n;i++)
	  {
	  	int k=99999;
	  	while(a[i].p<=k)
	  	  {
	  	  	k/=10;
	  	  	putchar('0');
		  }
		printf("%d",a[i].p);
		k=99999;
		while(a[i].ID<=k)
		  {
		  	k/=10;
		  	putchar('0');
		  }
		printf("%d\n",a[i].ID);
	  }
}

Measured memory_bytes: 3456
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
// ll MOD = 1000000007;
ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
int N,K;
ll gcd(ll a, ll b) {
	return b != 0 ? gcd(b, a % b) : a;
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}
// a x + b y = gcd(a, b)
ll extgcd(ll a, ll b, ll &x, ll &y) {
	ll g = a; x = 1; y = 0;
	if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
	return g;
}
ll invMod(ll a, ll m) {
	ll x, y;
	if (extgcd(a, m, x, y) == 1) return (x + m) % m;
	else                         return 0; // unsolvable
}



ll powMod(ll x, ll k, ll m) {//x^k (mod n)
	if (k == 0)     return 1;
	if (k % 2 == 0) return powMod(x*x % m, k/2, m);
	else            return x*powMod(x, k-1, m) % m;
}
int main(){
	ll N;
	cin>>N;
	N/=2;
	ll ans=powMod(3,2*N,MOD);
	ll fu=0;
	ll kumi=1;
	ll po2=1;
	for(int i=0;i<=N-1;i++){
		ll hoge=(kumi*po2)%MOD;
		hoge*=2;
		hoge%=MOD;
		ans-=hoge;
		ans+=MOD;
		ans%=MOD;
		kumi*=(2*N-i);
		kumi%=MOD;
		kumi*=invMod(i+1,MOD);
		kumi%=MOD;
		po2*=2;
		po2%=MOD;
	}
	cout<<ans<<endl;


}

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

using ll = long long;
const int INF = 1e9 + 1;


int main(){

	string S;
	cin >> S;

	ll ans = 0;

	for (int bit = 0; bit < (1 << 3); bit++) {
		int now = S[0]-'0';

		for (int i = 0; i < 3; i++) {
			if (bit & (1 << i))
				now += S[i+1] - '0';
			else
				now -= S[i+1] - '0';
		}

		if (now == 7) {
			for (int i = 0; i < 3; i++) {
				cout << S[i];
				if (bit & (1 << i))
					cout << "+";
				else
					cout << "-";
			}
			cout << S[3] << "=7" << endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>
using namespace std;

//#include<bits/stdc++.h>


int main() {
	
	int n;
	cin >> n;
	map<long long int,long long int>x;
	x[0] = 1;
	long long int p = 0;
	long long int ans = 0;
	while (n--) {
		int y;
		cin >> y;
		p += y;
		ans += x[p];
		x[p]++;

	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 12800
H, W = map(int, input().split())

_S = [input() for _ in range(H)]
S = [[0] * W for _ in range(H)]
for i in range(H):
    for j in range(W):
        S[i][j] = _S[i][j]

from collections import deque
queue = deque()

cost = [[-1] * W for _ in range(H)]

def bfs():
    dx = [0, 1, 0, -1]
    dy = [1, 0, -1, 0]

    queue.append([0, 0])
    cost[0][0] = 0

    while len(queue) > 0:
        x, y = queue.popleft()
        if x == W - 1 and y == H - 1:
            return cost[y][x]

        for i in range(4):
            nx = x + dx[i]
            ny = y + dy[i]

            if nx < 0 or ny < 0 or nx >= W or ny >= H:
                continue
            if S[ny][nx] == "#":
                continue
            if cost[ny][nx] != -1:
                continue
            cost[ny][nx] = cost[y][x] + 1
            queue.append([nx, ny])
    return -1

min_cost = bfs()

import numpy as np
num_white = (np.array(S) == ".").sum(axis=1).sum() - 2

print(-1 if min_cost == -1 else num_white - (min_cost - 1))


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

using namespace std;

#define int long long

signed main(){
  int n;
  cin >> n;
  vector<int> a;
  for (int i=0;i<n;i++){
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
  sort(a.begin(),a.end());
  int ans = 0;
  for(int i=a.size()-1;i>=2;i--){
    for(int j=0;j<i-1;j++){
      for(int k=j+1;k<i;k++){
        if(a[j] + a[k] > a[i]) ans++;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
nlen = len(str(n))
ans = 0
if nlen % 2 != 0:
    ans += n - 10 ** (nlen - 1) + 1
for i in range(nlen):
    if i % 2 != 0:
        ans += 10 ** i - 10 ** (i - 1)
print(ans)

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

#define int long long
const int maxn = 2e5 + 5, mod = 1e9 + 7;

int P[maxn], sz[maxn], p[maxn];
vector <int> adj[maxn];

void getsz(int v, int par = -1) {
	p[v] = par;
	sz[v] = 1;
	for (auto u: adj[v]) {
		if (u != par) {
			getsz(u, v);
			sz[v] += sz[u];
		}
	}
}

int po(int a, int b) {
	if (b == 0)
		return 1;
	int y = po(a, b / 2);
	y *= y;
	y %= mod;
	if (b % 2)
		return y * a % mod;
	return y;
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	P[0] = 1;
	for (int i = 1; i <= n; i++)
		P[i] = P[i - 1] * 2 % mod;
	int inv = po(P[n], mod - 2);
	for (int i = 0; i < n - 1; i++) {
		int v, u;
		cin >> v >> u;
		v--;
		u--;
		adj[v].push_back(u);
		adj[u].push_back(v);
	}
	getsz(0);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		ans += po(2, mod - 2);
		ans -= inv;
		for (auto u: adj[i]) {
			if (p[i] != u) {
//				cout << i << ' ' << u << ' ' << P[sz[u]] - 1 << ' ' << ans << endl;
				ans -= (P[sz[u]] - 1) * inv % mod;
//				cout << ans << endl;
				ans %= mod;
				ans += mod;
				ans %= mod;
			}
		}
//		cout << i << ' ' << p[i] << ' ' << P[n - sz[i]] - 1 << endl;
		ans -= (P[n - sz[i]] - 1) * inv % mod;
		ans %= mod;
		ans += mod;
		ans %= mod;
	}
	cout << ans;
}


Measured memory_bytes: 22912
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<cstring>
#include<sstream>
using namespace std;

typedef long long ll;

int main() {
  int N; cin >> N;
  int a[300010];
  for ( int i = 0; i < 3*N; i++ ) cin >> a[i];
  sort(a,a+3*N);

  ll ans = 0;
  for ( int i = 3*N-1; i >= N; i-=2 ) {
    ans += a[i-1];
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
	int A,B;
  	cin >> A >> B;
  
  	int wa = A + B, sa = A - B, se = A * B;
  	
  	if(wa > sa) {
     	if(wa > se) {
        cout << wa << endl;
        } else {
        cout << se << endl;
        }
    }else {
    	if(sa > se) {
        cout << sa << endl;
        }else {
        cout << se << endl;
        }
    }
}

Measured memory_bytes: 256
n,m=map(int,input().split())
A=[0 for s in range(n)]
B=[]
sum=0
for l in range(n):
    A[l]=list(map(int,input().split()))
for k in range(m):
    B.append(int(input()))
for w in range(n):
    for t in range(m):
        sum+=A[w][t]*B[t]
    print(sum)
    sum=0


Measured memory_bytes: 6016
import java.util.Arrays;
import java.util.Scanner;

class Main {
	double[][] p = new double[2][6];

	void run() {
		Scanner sc = new Scanner(System.in);
		int Na = sc.nextInt();
		int Nb = sc.nextInt();
		long[] xa = new long[Na];
		long[] ya = new long[Na];
		long[] xb = new long[Nb];
		long[] yb = new long[Nb];
		for (int i = 0; i < Na; ++i) {
			xa[i] = sc.nextLong();
			ya[i] = sc.nextLong();
		}
		for (int i = 0; i < Nb; ++i) {
			xb[i] = sc.nextLong();
			yb[i] = sc.nextLong();
		}

		double ans = Double.MAX_VALUE / 3;
		for (int t = 0; t < 2; ++t) {
			for (int i = 0; i < Na; ++i) {
				for (int j = 0; j < Na; ++j) {
					if (cross(xa[0], ya[0], xa[i], ya[i], xb[0], yb[0], xb[1], yb[1])) {
						continue;
					}
					if (cross(xa[i], ya[i], xa[j], ya[j], xb[0], yb[0], xb[1], yb[1])) {
						continue;
					}
					if (cross(xa[j], ya[j], xa[1], ya[1], xb[0], yb[0], xb[1], yb[1])) {
						continue;
					}
					ans = Math.min(ans, dist(xa[0], ya[0], xa[i], ya[i]) + dist(xa[i], ya[i], xa[j], ya[j])
							+ dist(xa[j], ya[j], xa[1], ya[1]) + dist(xb[0], yb[0], xb[1], yb[1]));
				}
			}
			Na ^= Nb;
			Nb ^= Na;
			Na ^= Nb;
			long[] tmp = new long[Na];
			tmp = Arrays.copyOf(xa, xa.length);
			xa = Arrays.copyOf(xb, xb.length);
			xb = Arrays.copyOf(tmp, tmp.length);
			tmp = Arrays.copyOf(ya, ya.length);
			ya = Arrays.copyOf(yb, yb.length);
			yb = Arrays.copyOf(tmp, tmp.length);
		}
		System.out.println(ans >= Double.MAX_VALUE / 4 ? "-1" : ans);
	}

	double dist(long xa, long ya, long xb, long yb) {
		long dx = xa - xb;
		long dy = ya - yb;
		return Math.sqrt(dx * dx + dy * dy);
	}

	boolean cross(long xa1, long ya1, long xb1, long yb1, long xa2, long ya2, long xb2, long yb2) {
		long v = f(xa1, ya1, xb1, yb1, xa2, ya2) * f(xa1, ya1, xb1, yb1, xb2, yb2);
		long u = f(xa2, ya2, xb2, yb2, xa1, ya1) * f(xa2, ya2, xb2, yb2, xb1, yb1);
		return v <= 0 && u <= 0;
	}

	long f(long xa, long ya, long xb, long yb, long x, long y) {
		return (ya - yb) * (x - xa) - (y - ya) * (xa - xb);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

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


Measured memory_bytes: 36512
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;

#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 

#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
#define len length
#define ret0 return 0
#define ret return 

#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)

#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>

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

#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN 100001

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

    ll n;
    cin>>n;
    ll a[n+1];
    ll sum=0;
    loop(i,1,n+1) {
        cin>>a[i];
        sum+=a[i];
    }
    ll m[n+1];
    m[1]=sum;
    for(ll i=2; i<=n; i+=2){
        m[1]-=2*a[i];
    }
    for(ll i=2; i<=n; i++){
        m[i]=2*a[i-1]-m[i-1];
    }
    loop(i,1,n+1){
        cout<<m[i]<<" ";
    }
    cout<<endl;

   
}



Measured memory_bytes: 2944
n,a,b = map(int,input().split())

mod = 10 ** 9 + 7
k = max(a,b)
com = [1]

for i in range(1,k+1):
    com.append((com[i-1]*(n-i+1)*pow(i,mod-2,mod))%mod)

print((pow(2,n,mod)-1-com[a]-com[b])%mod)

Measured memory_bytes: 11052
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>
#include <cassert>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
	string s,t;
    int n,a,b,c,d,e,x,y;
    cin >> n;
	if(n <600){
		cout << 8;
	}else if(n < 800){
		cout << 7;
	}else if(n < 1000){
		cout << 6;
	}else if(n < 1200){
		cout << 5;
	}else if(n < 1400){
		cout << 4;
	}else if(n < 1600){
		cout << 3;
	}else if(n < 1800){
		cout << 2;
	}else if(n < 2000){
		cout << 1;
	}
	cout << endl;
}


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

	int n, a, b;

	cin >> n >> a >> b;

	if (n*a > b)
	{
		cout << b;
	}
	else
	{
		cout << n*a;
	}

    return 0;
}



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

import static java.lang.Integer.parseInt;

/**
 * Sugoroku
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		int N = parseInt(br.readLine());
		int count = 0;
		int max = 0;

		StringTokenizer st = new StringTokenizer(br.readLine());

		while (st.hasMoreTokens()) {
			if (st.nextToken().equals("1")) {
				count++;
			} else {
				count = 0;
			}
			max = Math.max(max, count);
		}

		System.out.println(max + 1);
	}
}


Measured memory_bytes: 24432
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		
		int n=in.nextInt(),m=(int)Math.pow(2, n)-1;
		PrintWriter out=new PrintWriter(System.out);
		for(int i=0;i<=m;i++){
			String str=Integer.toBinaryString(i);
//			System.out.println(str);
			
			List<Integer> ls=new ArrayList<>();
			for(int j=0;j<str.length();j++){
				if(str.charAt(str.length()-1-j)=='1')ls.add(j);
			}
			
			out.print(i+":");
			for(int j=0;j<ls.size();j++)out.print(" "+ls.get(j));
			out.println();
		}
		out.flush();
	}

}



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

constexpr int mod = 1e9 + 7, inv2 = 500000004;

int main() {
  int N;
  string s;

  cin >> N >> s;

  vector<vector<int>> dp(N + 1, vector<int>(N + 1));
  dp[0][0] = 1;

  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      (dp[i + 1][j + 1] += 2 * dp[i][j] % mod) %= mod;
      (dp[i + 1][max(0, j - 1)] += dp[i][j]) %= mod;
    }
  }

  int64_t ans = dp[N][s.size()];
  for (int i = 0; i < s.size(); ++i) {
    (ans *= inv2) %= mod;
  }

  cout << ans << endl;
}


Measured memory_bytes: 98176
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x;
    cin >> x;
    int h = (x/500)*1000;
    x %= 500;
    h += (x/5)*5;
    cout << h << '\n';
    return 0;
}


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

int main(){
  int i,j;
  int n,m;
  
  while(1){
    cin >> n >> m;
    if(n==0 && m==0){
      break;
    }
    if(n<3 && m<3){ 
      for(i=0;i<n;i++){
	for(j=0;j<m;j++){
	  cout << "#";
	}
      }
    } 
    if(n>=3 && m>=3){
      for(i=0;i<m;i++){
	cout << "#";
      }
      cout << endl;
      for(i=0;i<n-2;i++){
	cout << "#";
	for(j=0;j<m-2;j++){
	  cout << ".";
	}
	cout << "#";
	cout << endl;
      }
      for(i=0;i<m;i++){
	cout << "#";
      }
      cout << endl;   
    } 
    cout << endl;  
  }
  return 0;
}

Measured memory_bytes: 1152
//HOW YOU DOI'N........................JT
//Could this code be more bad..........CB
//I know...............................MG
//Hii..................................RG
//Noooooooo............................RG
//I wish I could but I don't want to...PB

//That's what she said.................MS


#include <bits/stdc++.h>

#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);

#define ll long long
#define ld long double
#define pb push_back
#define mkpr make_pair
#define fi(i,a,b) for (ll i=a;i<b;i++)
#define vll vector<ll>
#define vch vector<char>
#define vst vector<string>
#define vpll vector<pll>
#define vvl vector<vector<ll>>
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(v.rbegin(), v.rend())
#define mxe(v) *max_element(v.begin(),v.end())
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define mll map<ll, ll>
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a)*1ll * (b)) / gcd(a, b)
#define nl "\n"
#define sp " "
#define sz(x)  (int)x.size()

using namespace std;

double PI = (acos(-1));
ll md = 1000000007;
//ll md = 998244353;

ll pw(ll a, ll b){ll c=1,m=a;while (b){if (b&1)c=(c*m);m=(m*m);b/=2;}return c;}
ll pwmd(ll a, ll b){ll c = 1, m = a;while (b){if (b & 1)c = ((c * m)) % md;m = (m * m) % md;b /= 2;}return c;}
ll modinv(ll n){return pwmd(n, md - 2);}
ll min(ll a,ll b){if(a>=b)return b;return a;}
ll nc2(ll n){return (1ll * n * (n - 1)) / 2;}
ll nsum(ll n){return (1ll * n * (n + 1)) / 2;}
bool prime(ll a){for(int i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}

#define MAX_SIZE 100005
void Sieve(vector<int> &primes){bool IsPrime[MAX_SIZE];memset(IsPrime, true, sizeof(IsPrime));
for (int p = 2; p * p < MAX_SIZE; p++){if (IsPrime[p] == true){
			for (int i = p * p; i < MAX_SIZE; i += p)IsPrime[i] = false;}}
	for (int p = 2; p < MAX_SIZE; p++)if (IsPrime[p])primes.push_back(p);}


vector<char> sml={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char> cap={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};





// Lets start ...


void solve(){
    ll n;
    cin>>n;
    ll i=1,sum=0;
    while(true){
        if(i==11)break;
        sum+=pw(26,i);
        if(sum>=n)break;
        i++;
    }
    fi(j,0,i)n-=pw(26,j);
    string s="";
    fi(j,0,i){
        s+='a'+(n/pw(26,i-j-1));
        n-=((n/pw(26,i-j-1))*pw(26,i-j-1));
    }
    cout<<s;
    
    
}

int main(){
    //vector<int> primes;
    //Sieve(primes);
    
    fast
    ll tests=1,cnt=0;
    //cin>>tests;
    while(tests--){
        solve();
    }
    

    return 0;
    }

// Done:)




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

#define debug(a) cerr << #a << " = " << (a) << endl;
#define fst first
#define snd second
#define sz(x) (int)(x).size()
#define all(X) begin(X), end(X)

typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> pii;

template<typename T, typename U> ostream& operator<<(ostream& o, const pair<T, U>& x) { 
  o << "(" << x.fst << ", " << x.snd << ")"; return o;
}

template<typename T> ostream& operator<<(ostream& o, const vector<T>& x) {
  o << "["; int b = 0; for (auto& a : x) o << (b++ ? ", " : "") << a; o << "]"; return o;
}

template<typename T> ostream& operator<<(ostream& o, const set<T>& x) {
  o << "{"; int b = 0; for (auto& a : x) o << (b++ ? ", " : "") << a; o << "}"; return o;
}

template<typename T, typename U> ostream& operator<<(ostream& o, const map<T, U>& x) {
  o << "{"; int b = 0; for (auto& a : x) o << (b++ ? ", " : "") << a; o << "}"; return o;
}

const int N = 100005;

int n;
int A[N], B[N], C[N];
int dp[N][2][2][2];

//f(i) gives maximum happiness starting at day i
int f(int day, int a, int b, int c) {
  if(day == n) return 0;
  
  int& x = dp[day][a][b][c];
  if(x != -1) return x;

  if(a) x = A[day] + f(day+1, 0, 1, 1);
  if(b) x = max(x, B[day] + f(day+1, 1, 0, 1));
  if(c) x = max(x, C[day] + f(day+1, 1, 1, 0));

  return x;
}


int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  
  cin >> n;
  for(int i = 0; i < n; ++i) {
    cin >> A[i] >> B[i] >> C[i];
  }

  for(int i = 0; i < n; ++i) {
    for(int j = 0; j < 2; ++j) {
      for(int k = 0; k < 2; ++k) {
        for(int l = 0; l < 2; ++l) {
          dp[i][j][k][l] = -1;
        }
      }
    }
  }

  cout << f(0, true, true, true) << endl;
}



Measured memory_bytes: 12416
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
 
using namespace std;
 
#define int long long
 
signed main(){
	// int z=200001;
	vector<int> v1;
	vector<int> v2;

	int n,m,tmp;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>tmp;
		v1.push_back(tmp);
	}

	cin>>m;
	for(int i=0;i<m;i++){
		cin>>tmp;
		v2.push_back(tmp);
	}

	sort(v1.begin(),v1.end());
	sort(v2.begin(),v2.end());

	// for(int i=0;i<n;i++){
	// 	cout<<v1[i]<<" ";
	// }cout<<endl;

	// 	for(int i=0;i<m;i++){
	// 	cout<<v2[i]<<" ";
	// }cout<<endl;


	int hoge1=0;
	int hoge2=0;

	int abc=0;
	int count=0;
	while(1){


		// abc++;
		// if(abc==10)break;
		if(hoge1+1==n){
			if(v1[hoge1]!=v2[hoge2]){
				cout<<"NO"<<endl;
				return 0;
			}
		}


		// cout<<abc<<endl;
		// cout<<"hoge1:"<<hoge1<<" "<<"hoge2:"<<hoge2<<endl;
		// cout<<v1[hoge1]<<" "<<v2[hoge2]<<endl;

		if(v1[hoge1]!=v2[hoge2])hoge1++;
		else if(v1[hoge1]==v2[hoge2]){


			++count;


						// cout<<"count++"<<endl;

			hoge1++;
			hoge2++;
		}

		if(count==m){

			cout<<"YES"<<endl;
			break;
		}
	}
}

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

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

    vector<int> vec(N);
    for(int i=0; i<N; i++){
        cin >> vec.at(i);
    }

    vector<int> x = vec; 

    sort(x.begin(), x.end());

    int cnt=0;

    for(int i=0; i<N; i++){
        if(vec.at(i)!=x.at(i)){
            cnt++;
        }
    }

    if(cnt<=2){
        cout << "YES" <<endl;
    }

    else {
        cout << "NO" <<endl;
    }

}

Measured memory_bytes: 256
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = input()
#  = int(input())
n, m  = map(int, input().split())
x  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

x.sort()
q = [x1 - x2 for x1, x2 in zip(x[1:], x[:-1])]
q = sorted(q)[::-1]

print(sum(q[n-1:]))



Measured memory_bytes: 13832
/**
n×m  の行列 A  と m×l  の行列 B  を入力し、それらの積である n×l  の
 を出力するプログラムを作成してください。行列 C  の各要素 c ij   は次の式で得られます：

 １行目に n 、m 、l  が空白区切りで与えられます。

続く行に n×m  の行列 A  と m×l  の行列 B  が与えられます。

 */

//スキャナつかうため

import java.util.Scanner;

public class Main {
	// プログラムのエントリポイント
	public static void main(String[] args) {
		// 入力ストリームの生成
		Scanner sc = new Scanner(System.in);
		// 3つの数値を受け取る
		int intN = sc.nextInt();
		int intM = sc.nextInt();
		int intL = sc.nextInt();
		// 受け取った数値で配列をつくる
		// Aの行列
		int[][] gyoua = new int[intN][intM];
		// Bの行列
		int[][] gyoub = new int[intM][intL];
		// Cの行列
		long[][] gyouc = new long[intN][intL];
		// 数値をAの配列の数受け取る
		for (int i = 0; i < intN; i++) {
			for (int j = 0; j < intM; j++) {
				gyoua[i][j] = sc.nextInt();
			}
		}
		// Bの配列の数数値を受け取る
		for (int i = 0; i < intM; i++) {
			for (int j = 0; j < intL; j++) {
				gyoub[i][j] = sc.nextInt();
			}
		}
		// 計算
		for (int i = 0; i < intN; i++) {
			for (int j = 0; j < intL; j++) {

				for (int k = 0; k < intM; k++) {
					// Cの配列に計算結果を入れていく
					gyouc[i][j] += gyoua[i][k] * gyoub[k][j];
				}
				System.out.print(gyouc[i][j]);
				if (j != intL - 1) {
					// 空白
					System.out.print(" ");
				}
			}
			// 改行
			System.out.println();
		}

	}
}

Measured memory_bytes: 44872