akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    const int U = 4;    //S_iは高々U文字

    //dp[i][j] : 最後の文字列がj文字のときのi文字目までの分割の最大個数
    int dp[n+1][U+1];   

    rep(i, n+1) {
        rep(j, U+1) {
            dp[i][j] = -1;
        }
    }
    
    dp[0][0] = 0;
    //i文字目まで最大個数に分割したとする
    rep(i, n) {
        //最後の文字列はj文字とする
        rep(j, U+1) {
            if(dp[i][j] == -1) {
                continue;
            }
            //次の文字列がk文字とする
            //i+k <= n かつ k <= U をみたすことが必要
            for(int k = 1; i+k <= n && k <= U; k++) {
                //次の文字列がk文字でだいじょうか？
                //k != j のときは文字数が異なるのでok
                //k == j のときは最後のj文字と次のk文字が異なればok
                if( k != j || s.substr(i-j, j) != s.substr(i, k) ) {
                    /* 最後の文字列がk文字のときのi+k文字目までの分割の
                       個数の最大値は、 */
                    dp[i+k][k] = max(dp[i+k][k], dp[i][j] + 1);
                }
            }
        }
    }

    int ans = 0;
    rep(j, U+1) {
        ans = max(ans, dp[n][j]);
    }

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

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

int main() {
  int n,count;
  cin >> n;
  count=0;
  vector <int> a(100);
   vector <int> b(100);
   vector <int> c(100);
  for(int i=0;i<n;i++)
  cin >> a.at(i);
  for(int i=0;i<n;i++)
  cin >> b.at(i);
  for(int i=0;i<n-1;i++)
  cin >> c.at(i);
  
  for (int i=0;i<n;i++){
  count+=b.at(a.at(i)-1);
    if(a.at(i)+1==a.at(i+1)){
    count+=c.at(a.at(i)-1);
    }
  }
  cout << count <<endl;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
 
 
 
class Solve
{
    public Solve() { }
    public static int Main()
    {
        new Solve().calc();
        return 0;
    }
 
 
    Scanner cin;
 
    void calc()
    {
        cin = new Scanner();
        var A = cin.nextInt();
        var B = cin.nextInt();
        var K = cin.nextInt();

        var NumList = new List<int>();
        for (int i = 0; i < K; i++)
        {
            if (A + i <= B)
                NumList.Add(A + i);

            if (B - i >= A)
                NumList.Add(B - i);
        }
        NumList.Sort();
        var result = NumList.Distinct();

        foreach (var res in result)
        {
            Console.WriteLine(res);
        }

    }
}
 
class Scanner
{
    string[] s;
    int i;
 
    char[] cs = new char[] { ' ' };
 
    public Scanner()
    {
        s = new string[0];
        i = 0;
    }
 
    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }
 
    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }
 
    public long nextLong()
    {
        return long.Parse(next());
    }
 
    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }
 
    public double nextDouble()
    {
        return double.Parse(next());
    }
 
 
    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr long long LLINF = 1LL << 62;
constexpr double EPS = 1e-9;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
  }
} initializer;

template<typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (T &x : vec) is >> x;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    if (it != vec.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &pa) {
  return os << "(" << pa.first << ", " << pa.second << ")";
}

template<typename Tuple, size_t N>
struct TuplePrinter {
  static void print(const Tuple &t) {
    TuplePrinter<Tuple, N-1>::print(t);
    cout << ", " << get<N-1>(t);
  }
};

template<typename Tuple>
struct TuplePrinter<Tuple, 1> {
  static void print(const Tuple &t) {
    cout << get<0>(t);
  }
};

template<typename... T>
ostream &operator<<(ostream &os, const tuple<T...> &tup) {
  os << "(";
  TuplePrinter<decltype(tup), sizeof...(T)>::print(tup);
  return os << ")";
}

template<typename T>
ostream &operator<<(ostream &os, const set<T> &se) {
  os << "{";
  for (auto it = se.begin(); it != se.end(); ++it) {
    if (it != se.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &ma) {
  os << "{";
  for (auto it = ma.begin(); it != ma.end(); ++it) {
    if (it != ma.begin()) os << ", ";
    os << it->first << ": " << it->second;
  }
  return os << "}";
}

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }
#define dump(...) cout<<#__VA_ARGS__<<": [L_"<<__LINE__<<"]"<<'\n'; print(__VA_ARGS__);cout<<'\n';

template<class T, class U>inline bool chmax(T &a, const U &b) { if(a<b){ a=b; return 1; } return 0; }
template<class T, class U>inline bool chmin(T &a, const U &b) { if(b<a){ a=b; return 1; } return 0; }


int main() {
  char c; cin>>c;
  print(char(c+1));

  return 0;
}

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

// ÄAÉæé2iñ
void rec(int depth, int max_depth, int a[], int &cnt) {
  if ( depth == max_depth ) {
    cnt++;
    return;
  }
  
  for(int i = 0; i < 2; i++) {
    a[depth] = i;
    rec(depth + 1, max_depth, a, cnt);    
  }  
}

int main() {  
  int a[128];
  int cnt = 0;
  int max_depth = 26;
  rec(0, max_depth, a, cnt);
  
  for(int a = 1; a <= 9; a++)
    for(int b = 1; b <= 9; b++)
      printf("%dx%d=%d\n", a, b, a * b);
  return 0;
}

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

using namespace std;

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

    vector<int> l(m), r(m), key(n + 1, 1);
    for (int i = 0; i < m; i++)
    {
        cin >> l[i] >> r[i];
    }

    for (int i = 0; i < m; i++)
    {
        for (int j = l[i] - 1; j > 0; j--)
        {
            if (key[j] == -1)
            {
                break;
            }
            key[j] = -1;
        }
        for (int j = r[i] + 1; j < n + 1; j++)
        {
            if (key[j] == -1)
            {
                break;
            }
            key[j] = -1;
        }
    }

    int ans = 0;
    for (int i = 1; i < n + 1; i++)
    {
        if (key[i] == 1)
        {
            ans += 1;
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> w(n);
  int sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> w.at(i);
    sum += w.at(i);
  }
  int l, r;
  l = 0;
  int res = 10000000;
  for (int i = 0; i < n - 1; i++) {
    l += w.at(i);
    r = sum - l;
    res = min(res, abs(l - r));
  }
  cout << res << endl;
}




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

signed main(){
  lint N, P; cin >> N >> P;
  vector<lint> a(N);
  lint num = 0;
  for(lint i = 0; i < N; i++) {
    cin >> a[i];
  }
  vector<pair<lint, lint> > dp(N + 1);
  dp[0].first = 1;
  dp[0].second = 0;
  for(lint i = 0; i < N; i++){
    if(a[i] % 2 == 0){
      dp[i + 1].first = dp[i].first * 2;
      dp[i + 1].second = dp[i].second * 2;
    }
    else{
      dp[i + 1].first = dp[i].first + dp[i].second;
      dp[i + 1].second =  dp[i].first + dp[i].second;
    }
  }
  if(P == 0) cout << dp[N].first << endl;
  else cout << dp[N].second << endl;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline

n,m = map(int, input().split())
link = [[] for _ in range(n)]
for i in range(m):
    tmp = list(map(int,input().split()))
    link[tmp[0]-1].append([tmp[1]-1,tmp[2]])
    link[tmp[1]-1].append([tmp[0]-1,-tmp[2]])
from collections import deque
INF=10**10
dist=[INF]*n
for i in range(n):
    if dist[i]!=INF:
        continue
    dist[i]=0
    Q = deque()
    Q.append([i,0])
    while Q:
        now,cnt = Q.popleft()
        for nxt,nxt_dist in link[now]:
            if dist[nxt] == INF:
                dist[nxt] = cnt+nxt_dist
                Q.append([nxt,cnt+nxt_dist])
            elif dist[nxt] != cnt+nxt_dist:
                    print("No")
                    exit()

print("Yes")

Measured memory_bytes: 103072
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

int main() {
  int n; cin >> n;
  int ans = 0;
  vector<int> d(n);
  for (int i = 0; i < n; i++) cin >> d[i];
  sort(d.begin(), d.end());

  int mid = (n / 2) - 1;
  if (d[mid] != d[mid + 1]) {
    ans = d[mid + 1] - d[mid];
  }

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


Measured memory_bytes: 640
//#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define pb push_back
#define INF 93193111451418101
#define MIN -93193111451418101
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
//----------program from here----------


string a,b,c;


int main(){
    cin>>a>>b>>c;
    string ab,bf,bb,cf;
    ab=a[a.length()-1];
    bf=b[0];
    bb=b[b.length()-1];
    cf=c[0];

    if(ab==bf && bb==cf){
      cout<<"YES";
      return 0;
    }
    cout<<"NO";    



    return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal, ROUND_CEILING
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
N, K = MAP()
A = LIST()

l = 0
r = 10**9+1
while l+1 != r:
    m = (l+r)//2
    cnt = 0
    for L in A:
        cnt += 0--L//m-1
        if cnt > K:
            ret = False
            break
    else:
        ret = True

    if ret:
        r = m
    else:
        l = m
print(l+1)


Measured memory_bytes: 33200
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;cin>>n>>k;
  vector<int>p(n),c(n);
  for(int i=0;i<n;i++){
    cin>>p.at(i);
    p.at(i)--;
  }
  for(int i=0;i<n;i++){
    cin>>c.at(i);
  }
  vector<vector<int>>G(n,vector<int>());
  int64_t ans=-1e18;
  for(int i=0;i<n;i++){
    int x=i;
    int64_t sum=0;
    int64_t tmp=0;
    while(1){
      G.at(i).push_back(c.at(x));
      sum+=c.at(x);
      x=p.at(x);
      if(x==i)break;
    }
    for(int j=0;j<k;j++){
      int roop_size=G.at(i).size();
      if(j>roop_size-1)break;
      tmp+=G.at(i).at(j);
      if(sum>0){
        ans=max(ans,tmp+sum*((k-j-1)/roop_size));
      }
      else{ans=max(ans,tmp);}
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 120892
#include <iostream>
#include <numeric>
#include <algorithm>

int main(void)
{
  int a,b,c;
  std::cin >> a >> b >> c;
  int s = a+b+c;
  int v[] = {a,b,c};
  s -= *std::max_element(v, v+3);

  std::cout << s << std::endl;

  return 0;
}




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

using namespace std;


void solve() {
    int n; cin >> n;
    string s;cin >> s;
    if (n % 2 == 0) {
        int m = n/2;
        bool yes = true;
        for (int i = 0; i < m; i++) {
            yes &= s[i] == s[i+m];
        }
        if (yes) {
            cout << "Yes"; return;
        }
    }
    cout << "No";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 256
/*⠄⢰⣧⣼⣯⠄⣸⣠⣶⣶⣦⣾⠄⠄⠄⠄⡀⠄⢀⣿⣿⠄⠄⠄⢸⡇⠄⠄
⠄⠄⠄⣾⣿⠿⠿⠶⠿⢿⣿⣿⣿⣿⣦⣤⣄⢀⡅⢠⣾⣛⡉⠄⠄⠄⠸⢀⣿⠄
⠄⠄⢀⡋⣡⣴⣶⣶⡀⠄⠄⠙⢿⣿⣿⣿⣿⣿⣴⣿⣿⣿⢃⣤⣄⣀⣥⣿⣿⠄
⠄⠄⢸⣇⠻⣿⣿⣿⣧⣀⢀⣠⡌⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠿⠿⣿⣿⣿⠄
⠄⢀⢸⣿⣷⣤⣤⣤⣬⣙⣛⢿⣿⣿⣿⣿⣿⣿⡿⣿⣿⡍⠄⠄⢀⣤⣄⠉⠋⣰
⠄⣼⣖⣿⣿⣿⣿⣿⣿⣿⣿⣿⢿⣿⣿⣿⣿⣿⢇⣿⣿⡷⠶⠶⢿⣿⣿⠇⢀⣤
⠘⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣽⣿⣿⣿⡇⣿⣿⣿⣿⣿⣿⣷⣶⣥⣴⣿⡗
⢀⠈⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⠄
⢸⣿⣦⣌⣛⣻⣿⣿⣧⠙⠛⠛⡭⠅⠒⠦⠭⣭⡻⣿⣿⣿⣿⣿⣿⣿⣿⡿⠃⠄
⠘⣿⣿⣿⣿⣿⣿⣿⣿⡆⠄⠄⠄⠄⠄⠄⠄⠄⠹⠈⢋⣽⣿⣿⣿⣿⣵⣾⠃⠄
⠄⠘⣿⣿⣿⣿⣿⣿⣿⣿⠄⣴⣿⣶⣄⠄⣴⣶⠄⢀⣾⣿⣿⣿⣿⣿⣿⠃⠄⠄
⠄⠄⠈⠻⣿⣿⣿⣿⣿⣿⡄⢻⣿⣿⣿⠄⣿⣿⡀⣾⣿⣿⣿⣿⣛⠛⠁⠄⠄⠄
⠄⠄⠄⠄⠈⠛⢿⣿⣿⣿⠁⠞⢿⣿⣿⡄⢿⣿⡇⣸⣿⣿⠿⠛⠁⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠉⠻⣿⣿⣾⣦⡙⠻⣷⣾⣿⠃⠿⠋⠁⠄⠄⠄⠄⠄⢀⣠⣴
⣿⣿⣿⣶⣶⣮⣥⣒⠲⢮⣝⡿⣿⣿⡆⣿⡿⠃⠄⠄⠄⠄⠄⠄⠄⣠⣴⣿*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl;

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

ll MAX(ll a){return a;}
ll MIN(ll a){return a;}
template<typename... Args>
ll MAX(ll a,Args... args){return max(a,MAX(args...));}
template<typename... Args>
ll MIN(ll a,Args... args){return min(a,MIN(args...));}

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

int n;
ll arr[205];
string s;

vector<ll> curr;

bitset<205> gauss[62];
bool ans[62];

bool can(vector<ll> num, ll goal){
	rep(x,0,62) gauss[x].reset();
	
	rep(bit,0,62){
		ans[bit]=goal&(1LL<<bit);
		rep(x,0,sz(num)) gauss[bit][x]=num[x]&(1LL<<bit);
	}
	
	/*
	rep(x,0,10){
		cout<<ans[x]<<" "<<gauss[x]<<endl;
	}
	cout<<endl;
	*/
	
	
	int curr=0;
	rep(x,0,62){
		if (curr==205) break;
		rep(y,x,62) if (gauss[y][curr]){
			swap(gauss[x],gauss[y]);
			swap(ans[x],ans[y]);
			break;
		}
		
		if (!gauss[x][curr]){
			curr++;
			x--;
			continue;
		}
		
		rep(y,x+1,62) if (gauss[y][curr]){
			gauss[y]^=gauss[x];
			ans[y]^=ans[x];
		}
		
		//cout<<x<<" "<<curr<<endl;
		curr++;
	}
	
	/*
	rep(x,0,10){
		cout<<ans[x]<<" "<<gauss[x]<<endl;
	}
	cout<<endl;
	*/
	
	rep(x,0,62) if (ans[x] && !gauss[x].any()) return false;
	return true;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int TC;
	cin>>TC;
	while (TC--){
		curr.clear();
	
		cin>>n;
		rep(x,0,n) cin>>arr[x];
		cin>>s;
		
		rep(x,n,0){
			if (s[x]=='0') curr.push_back(arr[x]);
			else{
				if (!can(curr,arr[x])){
					cout<<1<<endl;
					goto _end;
				}
			}
		}
		
		cout<<0<<endl;
		_end:;
	}
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#include <string>
#define rep(i, N) for(int (i)=0;(i)<(N);(i)++)
using namespace std;

int main(){
    int N, L;
    //map<string, int> S;
    string s;
    vector<string> S;
    cin >> N >> L;
    rep(i, N){
        cin >> s;
        S.push_back(s);
    }
    sort(S.begin(), S.end());
    rep(i, N){
        cout<<S[i];
    }
    cout<<endl;
}

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

using namespace std;

#define N 800
#define M 10000005

int n,m,p,pr[M],pre[N],tot,a[N],ans,num;
bool ok[M],vis[N];
vector<int> g[N];
map<int,int> mp;

bool dfs(int u){
	for (int v:g[u])
		if (!vis[v]){
			vis[v]=1;
			if (!pre[v]||dfs(pre[v])){pre[v]=u; return 1;}
		}
	return 0;
}

int main(){
	p=10000001;
	for (int i=2;i<=p;++i){
		if (!ok[i]) pr[++tot]=i;
		for (int j=1;j<=tot;++j){
			if (i*pr[j]>p) break;
			ok[i*pr[j]]=1;
			if (i%pr[j]==0) break;
		}
	}
	ok[1]=ok[2]=1;
	scanf("%d",&n);
	for (int i=1;i<=n;++i){
		int x; scanf("%d",&x);
		mp[x]^=1; mp[x+1]^=1;
	}
	for (auto i:mp){
		if (i.second) a[++m]=i.first;
	}
	for (int i=1;i<=m;++i){
		for (int j=1;j<i;++j)
			if (!ok[a[i]-a[j]]){
				g[i].push_back(j);
				g[j].push_back(i);
			}
	}
	for (int i=1;i<=m;++i){
		memset(vis,0,sizeof vis);
		if (a[i]&1){
			if (dfs(i)) ++ans;
			++num;
		}
	}
	ans+=((num-ans)/2+(m-num-ans)/2)*2+((num-ans)&1)*3;
	printf("%d\n",ans);
	
	return 0;
}
			

Measured memory_bytes: 14720
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;

#define ll long long
#define pal pair<ll,ll>
#define pad pair<double,double>
#define PB push_back
#define MP make_pair
#define F first
#define S second

const ll MOD = 1e9+7;
const ll INF = 1e18;
const double EPS = 1e-8;

long long MODPOW(long long x, long long n) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    return ret;
}

template<typename T,typename U>
bool chmax(T& max, const U& x){
	if(max<x){
		max = x;
		return true;
	}
	return false;
}

template<typename T,typename U>
bool chmin(T& min, const U& x){
	if(min>x){
		min = x;
		return true;
	}
	return false;
}


int main(){
	ll n;
    vector<ll> ans(4,0);
    vector<string> x={"AC","WA","TLE","RE"};
    cin >> n;
    for(ll i=0;i<n;i++){
        string tmp;
        cin >> tmp;
        for(ll j=0;j<4;j++){
            if(tmp==x[j]){
                ans[j]++;
            }
        }
    }
    for(ll i=0;i<4;i++){
        cout << x[i] << " x " << ans[i] << endl;
    }
}

Measured memory_bytes: 3624
// 素因数分解

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

/// Sieve of Eratosthenes　エラトステネスの篩
// https://youtu.be/UTVg7wzMWQc?t=2774
struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
  vector<pair<ll,int>> factor(ll x) {
    vector<pair<ll,int>> res;
    for (int p : primes) {
      int y = 0;
      while (x%p == 0) x /= p, ++y;
      if (y != 0) res.emplace_back(p,y);
    }
    if (x != 1) res.emplace_back(x,1);
    return res;
  }
};

// primesに素数列が入る

int main(){
    Sieve s(200000); // 使う素数の最大＞√(因数分解したい数)　大きすぎると遅い(10^７くらいまで)
    int X;
    cin>>X;
    auto itr=lower_bound(s.primes.begin(),s.primes.end(),X);
    cout<<*itr<<endl;
    return 0;
}

Measured memory_bytes: 4320
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'
int mod=1e9+7;

signed main(){
  vector<int> a(4);
  for(int i=0;i<4;i++)cin>>a[i];
  sort(a.begin(),a.end());
  if(a[0]==1&&a[1]==4&&a[2]==7&&a[3]==9)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		double N = sc.nextInt();
		sc.close();
		double s=N/3;
		System.out.println(s*s*s);
	}

}


Measured memory_bytes: 22484
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define m_p make_pair
#define sz(x) (int)x.size()
#define line cerr<<"--------------------\n";
#define see(x) cerr<<x<<" "
#define seeln(x) cerr<<x<<endl
#define out(x) cerr<<#x<<" = "<<x<<" "
#define outln(x) cerr<<#x<<" = "<<x<<endl
#define outarr(x,l,r) cerr<<#x"["<<l<<"-"<<r<<"] = "; for (int _i=l;_i<=r;++_i) cerr<<x[_i]<<" ";cerr<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define gc() getchar()
//char buf[1<<23],*p1=buf,*p2=buf;
//#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <class T> void read(T &x)
{
    x=0; char c=gc(); int flag=0;
    while (c<'0'||c>'9') flag|=(c=='-'),c=gc();
    while (c>='0'&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=gc();
    if (flag) x=-x;
}
template <class T> inline T _max(T a,T b){return a>b ? a : b;}
template <class T> inline T _min(T a,T b){return a<b ? a : b;}
template <class T> inline bool checkmax(T &a,T b){return b>a ? a=b,1 : 0;}
template <class T> inline bool checkmin(T &a,T b){return b<a ? a=b,1 : 0;}
const int N=10005,inf=1000000000;
int x;
void init()
{
	read(x);
}

void solve()
{
	printf("%d\n",1-x);
}

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


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

#define ll long long int
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define all(A) A.begin(), A.end()
#define sz(A) (int)A.size()
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <int, int> pii;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
const int inf = 1e9;
//const ll inf = 1e18;
const int N = 2e4;
ll dp[2][2019];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin >> s;
	int n = s.length();
	dp[0][s[0] - '0'] = 1;
	ll res = 0;
	for (int i = 1; i < n; i++) {
		for (int j = 0; j < 2019; j++) {
			int x = s[i] - '0';
			dp[i & 1][(x + 10 * j) % 2019] = dp[(i - 1) & 1][j];
		}
		dp[i & 1][s[i] - '0']++;
		res += dp[i & 1][0];
	}
	cout << res << "\n";
 	return 0;
}

Measured memory_bytes: 3800
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        String a;

        if (n%10==3) {
            a="bon";
        }else if(n%10==0||n%10==1||n%10==6||n%10==8){
            a="pon";
        }else {
            a="hon";
        }
        System.out.println(a);
    }
}


Measured memory_bytes: 35752
#include<cstdio>
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	int a[n][m]={};
	for(int i=0;i<n;i++){
		char s[m]={};
		scanf("%s",s);
		for(int j=0;j<m;j++){
			if(s[j]=='#')a[i][j]=1;
		}
	}
	int d[n+2][m+2]={};
	for(int i=0;i<n+2;i++){
		for(int j=0;j<m+2;j++){
			d[i][j]=10000000;
		}
	}
	int e=0;
	int x=-1;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(a[i][j]==0)x++;
		}
	}
	d[1][1]=0;
	for(int i=0;0==0;i++){
		for(int j=0;j<n;j++){
			for(int k=0;k<m;k++){
				if(d[j+1][k+1]>=10000000&&a[j][k]==0){
					int p=d[j][k+1]+1;
					int q=d[j+2][k+1]+1;
					int r=d[j+1][k]+1;
					int t=d[j+1][k+2]+1;
					if(d[j+1][k+1]>p&&a[j-1][k]==0)d[j+1][k+1]=p;
					if(d[j+1][k+1]>q&&a[j+1][k]==0)d[j+1][k+1]=q;
					if(d[j+1][k+1]>r&&a[j][k-1]==0)d[j+1][k+1]=r;
					if(d[j+1][k+1]>t&&a[j][k+1]==0)d[j+1][k+1]=t;
					if(d[j+1][k+1]<10000000)e++;
				}
			}
		}
		if(e==0){
			printf("-1");
			break;
		}
		if(d[n][m]<1000000){
			printf("%d\n",x-d[n][m]);
			break;
		}
		e=0;
	}
	return 0;
}	

Measured memory_bytes: 128
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define dump(x)  cout << #x << " = " << (x) << endl
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class AConnectionAndDisconnection {
public:
    void solve(std::istream& in, std::ostream& out) {
        string S;
        in >> S;
        string s1 = S;
        string s2 = S + S;
        string s3 = S + S + S;
        ll K;
        in >> K;
        ll answer = 0;
        if (S.size() == 1) {
            answer = K / 2;
        } else if (S.size() == 2) {
            answer = S[0] == S[1] ? K : 0;
        } else {
            int s1cnt = 0, s2cnt = 0, s3cnt = 0;
            REP(i,1,s1.size()) {
                if (s1[i-1] == s1[i]) {
                    s1[i] = '1';
                    s1cnt += 1;
                }
            }
            REP(i,1,s2.size()) {
                if (s2[i-1] == s2[i]) {
                    s2[i] = '1';
                    s2cnt += 1;
                }
            }
            REP(i,1,s3.size()) {
                if (s3[i-1] == s3[i]) {
                    s3[i] = '1';
                    s3cnt += 1;
                }
            }
            answer = s1cnt;
            answer += (K-1)/2 * (s3cnt - s1cnt);
            if ((K-1)%2 != 0) answer += s2cnt - s1cnt;
        }
        out << answer << "\n";
    }
};


int main() {
	AConnectionAndDisconnection solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
bool DFS(int t_b,int t_c,int th,int* balls){
  if(th==10)return true;
  if(t_b<balls[th]&&t_c<balls[th])
      if(t_b>t_c)return DFS(balls[th],t_c,th+1,balls);
      else return DFS(t_b,balls[th],th+1,balls);
  else if(t_b<balls[th])return DFS(balls[th],t_c,th+1,balls);
  else if(t_c<balls[th])return DFS(t_b,balls[th],th+1,balls);
  else return false;
}
int main(){
  int n;
  cin>>n;
  for(int j=0;j<n;j++){
    int balls[10];
    for(int i=0;i<10;i++)cin>>balls[i];
    int t_b=0,t_c=0;int drop_balls=0;
    if(DFS(0,0,0,balls))cout<<"YES";
    else cout<<"NO";
    cout<<endl;
  }
}



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

int main() {
   long long k,a,b;
   cin >> k >> a >> b;
   long long l=1;
   if(a+1>=b) cout << k+1 << endl;
   if(a+1<b&&k<=a ) cout << k+1 << endl;
   if(a+1<b && k>a){
		while (k>0){
		    if(l<a && k>=a-l){
				
				k-=(a-l);
				l=a;
			}
			else if(l<a && k<a-l){
			    l+=k;
				k=0;
			}
			else if(l>=a&&k>=2){
				l+=(b-a);
				k-=2;
			}	
			else if(k==1) {
				l++;
				k--;
			}
		}
		cout << l << endl;
   }
  
 
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);int j;
    for(int i=0;i<=4;i++){
       j =sc.nextInt();
      if(j==0){System.out.println(i+1);System.exit(0);}
    }
  }
}

Measured memory_bytes: 35860
import math
x, y = map(int, input().split())
if (2*x-y)%3 != 0 or (-x+2*y)%3 != 0:
    print(0)
    exit()
a = (2*x-y)//3
b = (-x+2*y)//3
if a < 0 or b < 0:
    print(0)
    exit()
def comb(n, r, mod):
    r = min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n+1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod
print(comb(a+b, a, 10**9+7))


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

int main() {
  int A, B, max;
  cin >> A >> B;
  for (int i = 0; i < 2; i++) {
    if (A > B) {
      max += A;
      A--;
    }
    else {
      max += B;
      B--;
    }
  }
  cout << max << endl;
  return 0;
}

Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n"

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

	int n;
	cin>>n;
	vd dp(n+1);
	dp[0]=1;
	rep(i,n){
		double a;
		cin>>a;
		vd ndp(n+1);
		rep(j,n){
			ndp[j]+=dp[j]*a;
			ndp[j+1]+=dp[j]*(1-a);
		}
		dp=ndp;
	}
	double out=0;
	rep(i,n+1)if(i<n-i)out+=dp[i];
	cout<<shosu(9)<<out<<endl;
}





Measured memory_bytes: 384
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

N, K = LI()
S = input()

positions = []
idx = 0
keep = None
while idx < N:
    if S[idx] == '0':
        if keep == None:
            keep = idx
    else:
        # 1の場合は無視
        if keep != None:
            positions.append([keep, idx])
            keep = None
        else:
            # keepしない場合
            keep = None
    idx += 1
else:
    if keep != None:
        positions.append([keep, keep+1])
#  print(positions)
if len(positions) == 0:
    print(N)
    exit()
elif len(positions) <= K:
    print(N)
    exit()

ans = 0

for idx in range(len(positions)):
    if idx + K - 1 > len(positions) - 1:
        break
    if idx == 0:
        left = 0
    else:
        left = positions[idx-1][1]

    if idx + K - 1 == len(positions)-1:
        end = N
    else:
        end = positions[idx+K-1+1][0]
    #  print(end, left)
    ans = max(ans, end - left)
print(ans)




    


Measured memory_bytes: 13780
#include <iostream>
#include <bitset>
#include <algorithm>
 
using namespace std;
 
bitset<10000> cookie[10];
 
///////////////////////////SubMain//////////////////////////////////
int main(int argc, char *argv[])
{
 
    int R, C;
	while(cin >> R >> C && R > 0)
	{
		int i, j;
		for (i = 0; i < R; ++i)
		{
			for (j = 0; j < C; ++j)
			{
				bool upwards;
				cin >> upwards;
				cookie[i][j] = upwards;
			}
		}
 
		// 在横向一共有2^R&#31181;&#21464;&#25442;
		int permute_r = 1 << R;
		int result = 0;
		for (i = 0; i < permute_r ; ++i)
		{
			// 完成当前的&#21464;&#25442;
			for (j = 0; j < R; ++j)
			{
				// &#36825;一行是否&#24212;当翻个面
				if (i & (1 << j))
				{
					cookie[j].flip();
				}
			}
			
 
			// &#23545;&#27599;一列分&#21035;算出朝上和朝下的煎&#39292;个数，取其最大&#20540;
			int possible_answer = 0;
			for (j = 0; j < C; ++j)
			{
				int up_cookie_count = 0;
				for (int k = 0; k < R; ++k)
				{
					if (cookie[k][j])
					{
						++up_cookie_count;
					}
				}
				possible_answer += max(up_cookie_count, R - up_cookie_count);
			}
			// &#32467;果取最大&#20540;
			result = max(result, possible_answer);
			
			// &#22797;原
			for (j = 0; j < R; ++j)
			{
				if (i & (1 << j))
				{
					cookie[j].flip();
				}
			}
		}
		cout << result << endl;
	}
 
    return 0;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll; typedef long double ld;
const int INF32 = 1e9+10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; cin >> N;
  int x[110], y[110], h[110];
  int idx;
  for (int i = 0; i < N; i++) {
    cin >> x[i] >> y[i] >> h[i];
    if (h[i] > 0)
      idx = i;
  }
  for (int i = 0; i <= 100; i++) {
    for (int j = 0; j <= 100; j++) {
      int H = abs(x[idx] - i) + abs(y[idx] - j) + h[idx];
      int cnt = 0;
      for (int n = 0; n < N; n++) {
        if (h[n] == max(H - abs(x[n]-i)-abs(y[n]-j), 0)) {
          cnt++;
        }
      }
      if (cnt == N) {
        cout << i << ' ' << j << ' ' << H << endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <set>
#include <cmath>
#include <string>
#include <algorithm>

using namespace std;

const int CMax = 100002;

int n, i, A[CMax];
long long sum;

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

    printf("%d\n", n-i+1);
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
if(a < b){
System.out.println("a < b");
}else if(a > b){
System.out.println("a > b");
}else{
System.out.println("a == b");
}
sc.close();
}
}


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

ll combination(int n,int r) {
  if ( r * 2 > n ) r = n - r;
  ll dividend = 1;
  ll divisor  = 1;
  for (int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}

int main() {
 int n,p; cin >> n >> p;
 vector<int> a(n);
 int cnt0=0,cnt1=0;
 rep(i,n){
   int ai;cin >> ai;
   int ad=ai%2;
   a[i]=ad;
   if(ad==1)cnt1++;
   else cnt0++;
 }

 ll power=pow(2,cnt0);
 ll sum=0;

 rep(i,cnt1+1){
   if(i%2==p){
     ll res=combination(cnt1,i)*power;
     sum+=res;
   }
 }
 cout << sum << endl;

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll math_pow(ll a,ll s){
	if(s==0){
		return 1;
	}else if(s==1){
		return a;
	}else if(s%2==0){
		return math_pow(a,s/2)*math_pow(a,s/2);
	}else{
		return math_pow(a,s/2)*math_pow(a,s/2)*a;
	}
}

ll m,k;
int main(){
	cin>>m>>k;
	ll q=math_pow(2,m);
	if(q-1<k){
		cout<<-1<<endl;
		return 0;
	}
	if(m==1&&k==1){
		cout<<-1<<endl;
		return 0;
	}
	if(k==0){
		for(int i=0;i<q;i++){
			cout<<i<<" ";
		}
		for(int i=q-1;i>=0;i--){
			cout<<i<<" ";
		}
		cout<<endl;
		return 0;
	}
	for(int i=0;i<q;i++){
		if(i!=k){
			cout<<i<<" ";
		}
		
	}
	cout<<k<<" ";
	for(int i=q-1;i>=0;i--){
		if(i!=k){
			cout<<i<<" ";
		}
	}
	cout<<k<<endl;
	return 0;
}
	

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

int n, v[30], c[30], Ans;

int main()
{
	scanf("%d", &n);
	for (int i=1; i<=n; i++) scanf("%d", &v[i]);
	for (int i=1; i<=n; i++) scanf("%d", &c[i]);
	for (int i=1; i<=n; i++)
		if (v[i]>c[i]) Ans+=(v[i]-c[i]);
	printf("%d\n", Ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin>>n>>m;
    int a[m];
    long long int sum = 0;
    for (int i = 0; i < m; i++) {
        cin>>a[i];
        sum += a[i];
    }
    if (n >= sum) {
        cout<<n - sum;
    }
    else {
        cout<<"-1";
    }
	return 0;
}

Measured memory_bytes: 3692
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

#define MAX_SIZE (200001)
#define debug(x) (cout << # x ": " << x << endl)
#define ll long long int
#define repeat(n) for (int i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()

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

    map<int, int> mf, pf;

    repeat(n + 1) {
        if (i == 0) continue;
        int a;
        cin >> a;
        if (a > MAX_SIZE) continue;
        if (0 < i - a && i - a <= MAX_SIZE) {
            if (mf.find(i - a) == mf.end()) mf[i - a] = 1;
            else ++mf[i - a];
        }
        if (i + a <= MAX_SIZE) {
            if (pf.find(i + a) == pf.end()) pf[i + a] = 1;
            else ++pf[i + a];
        }
    }

    ll res = 0;

    for (const auto& m: mf) {
        auto p = pf.find(m.first);
        if (p != pf.end()) {
            res += m.second * p->second;
        }
    }

    cout << res;

    return 0;
}

Measured memory_bytes: 15124
use proconio::{fastout, input};

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[fastout]
fn main() {
    input! {
        r: f64,
    }

    let ans = r * 2.0 * 3.141592;
    println!("{}", ans);
}


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

#define int long long
int a[101010];

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

  for (int i = 1; i < n; i++){
    cin >> a[i];
    a[i] += a[i - 1];
  }

  int sum = 0, now = 0;
  for (int i = 0; i < m; i++){
    int x;
    cin >> x;
    sum += abs(a[now + x] - a[now]);
    now += x;
  }

  cout << sum % 100000 << endl;
}

Measured memory_bytes: 3860
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=105;
int w[maxn],sum[maxn];
int main()
{
	int n;scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&w[i]);
		sum[i]=sum[i-1]+w[i];
	}
	int ans=1e8;
	for(int i=1;i<=n;i++)
	{
		ans=min(ans,abs(2*sum[i]-sum[n]));
	}
	cout<<ans<<endl;
 } 

Measured memory_bytes: 256
# coding: utf-8
import math
import sys

N = int(input())
Xi = list(map(int, input().split()))
Xi.sort()
min = Xi[0]
max = Xi[N-1]
tmp = 0
result = sys.maxsize
for i in range(min,max+1):
    for j in range(0,N):
        tmp += (Xi[j] - i)**2
    if tmp <= result:
        result = tmp
    tmp = 0

print(result)

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

#define ll long long
#define ull unsigned long long

using namespace std;

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

	if (s == "Sunny"){
	cout << "Cloudy" << "\n";
	}
	if (s == "Cloudy"){
	cout << "Rainy" << "\n";
	}
	if (s == "Rainy"){
	cout << "Sunny" << "\n";
	}


	return 0;
}


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

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

	if(A + B <= K) {
		A = 0;
		B = 0;
	} else if(A <= K) {
		B = B - K + A;
		A = 0;
	} else {
		A -= K;
	}

	cout << A << " " << B << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int K, ans = 0;
vector<int> path[100010];

// 頂点vの高さを返す
// 0に繋いだ場合は-1
int dfs(int v, int r) {
    int h = 0;

    for (int sv : path[v]) {
        h = max(h, dfs(sv, v) + 1);
    }

    if (h == K - 1 && r > 0) {
        ++ans;
        h = -1;
    }

    return h;
}

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

    for (int v = 0; v < N; ++v) {
        int p;
        cin >> p;
        --p;

        if (v == 0) {
            if (p != 0) ++ans;  // 首都の行き先は首都
        } else {
            path[p].push_back(v);
        }
    }

    dfs(0, -1);
    cout << ans << endl;
    return 0;
}


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

ll r, D, x;

void solve() {
  for (int i = 0; i < 10; i++) {
    cout << r * x - D << '\n';
    x = r * x - D;
  }
  return;
}

int main() {
  cin >> r >> D >> x;
  solve();
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n= sc.nextInt();

		int array[] = new int[n];

		for(int i = 0; i<n;i++){
			array[i] = sc.nextInt();
		}

		Arrays.sort(array);

		int array2[] = new int[n];

		for(int i=0;i<n;i++){
			array2[i] = array[n-i-1];
		}

		int a = 0;

		for(int i=0; i<n;i += 2){
			a += array2[i];
		}
		
		int b = 0;

		for(int i=1; i <n; i+=2){
			b += array2[i];
		}
		System.out.println(a-b);

		
	}
}



Measured memory_bytes: 23636
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
int MOD = 10000000;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

vector <int> conn[100050];
vector <int> son[100050];
int par[100050];
bool dchk[100050];
map <int, int> dp[100050];
void DFS1(int n) {
	dchk[n] = true;
	for (auto it : conn[n]) {
		if (dchk[it]) continue;
		son[n].push_back(it);
		par[it] = n;
		DFS1(it);
	}

	int s = 0, c = 0;
	for (auto it : son[n]) {
		s += dp[it][n];
		if (!dp[it][n]) c++;
	}
	if (c) s += c - 1;
	dp[n][par[n]] = s;
}
void DFS2(int n) {
	vector <pii> Vl;
	for (auto it : son[n]) Vl.emplace_back(dp[it][n], it);
	if (n != 1) Vl.emplace_back(dp[par[n]][n], par[n]);

	int s = 0, c = 0;
	for (auto it : Vl) {
		s += it.first;
		if (!it.first) c++;
	}

	for (auto it : Vl) {
		if (it.second == par[n]) continue;
		int ts = s, tc = c;
		ts -= it.first;
		if (!it.first) tc--;

		if (tc) ts += tc - 1;
		dp[n][it.second] = ts;
		DFS2(it.second);
	}
}

int main() {
	int N, i;
	scanf("%d", &N);
	for (i = 1; i < N; i++) {
		int t1, t2;
		scanf("%d %d", &t1, &t2);
		t1++, t2++;
		conn[t1].push_back(t2);
		conn[t2].push_back(t1);
	}
	DFS1(1);
	DFS2(1);

	int ans = INF;
	for (i = 1; i <= N; i++) {
		int s = 0, c = 0;
		for (auto it : conn[i]) {
			s += dp[it][i];
			if (!dp[it][i]) c++;
		}
		if (c) s += c - 1;
		ans = min(ans, s + 1);
	}
	return !printf("%d\n", ans);
}
//*/

Measured memory_bytes: 45824
#include <iostream>

const int P = (int)1e9 + 7;

int comb(int x, int y) {
  auto factorial = [](int n) -> int64_t {
    int64_t res = 1;
    for (int i = 2; i <= n; ++i) {
      res = res * i % P;
    }
    return res;
  };
  auto pow = [](int64_t x, int64_t y) -> int64_t {
    int64_t res = 1;
    while (y > 0) {
      if (y & 1) res = res * x % P;
      x = x * x % P;
      y >>= 1;
    }
    return res;
  };
  return factorial(x) * pow(factorial(x - y), P - 2) % 
         P * pow(factorial(y), P - 2) % P;
}

int solve(int n, int m) {
  if ((2 * m - n) % 3 != 0 || (2 * n - m) % 3 != 0) return 0;
  int x = (2 * m - n) / 3;
  int y = (2 * n - m) / 3;
  if (x < 0 || y < 0) return 0;
  return comb(x + y, x);
}

int main() {
  int n, m;
  std::cin >> n >> m;
  std::cout << solve(n, m) << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
          

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a , b;
    cin >> a >> b;
    string c[a];
    for ( int i = 0 ; i < a ; i++ ) {
        cin >> c[i];
    }
    for ( int i = 0 ; i < a ; i++ ) {
        cout << c[i] << endl << c[i] << endl;
    }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef map<int,int> mii;
typedef vector<int>vi;
#define pb push_back
#define sc(n) scanf("%d",&n)
#define lsc(n) scanf("%lld",&n)
#define all(x) x.begin(),x.end()
#define rep(i,n) for(i=0;i<n;i++)
#define rep1(i,n) for(i=1;i<=n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define rev1(i,n) for(i=n;i>0;i--)
#define in insert
#define pr(n) printf("%d\n",n)
#define lpr(n) printf("%lld\n",n);

int main()
{
	ll a,v,b,w,t;
	cin >> a >> v;
	cin >> b >> w;
	cin >> t;
	ll dis=abs(a-b);
	ll dv=v-w;
	if(dv<=0)
	{
		cout << "NO" << endl;
		return 0;
	}
	dis-=(dv*t);
	if(dis<=0)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
	return 0;
}


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

ll A, B;

ll f(ll a) {
  if (a % 4 == 0) {
    return a;
  }
  else if (a % 4 == 1) {
    return 1;
  }
  else if (a % 4 == 2) {
    return a + 1;
  }
  else {
    return 0;
  }
}

void abc121d() {
  ll ans = A ^ f(A) ^ f(B);
  cout << ans << '\n';
  return;
}

int main() {
  cin >> A >> B;
  abc121d();
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int llint;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (b < c) {
		swap(b, c);
	}
	if (a < b) {
		swap(a, b);
	}
	cout << b + c << endl;
	return 0;
}

Measured memory_bytes: 256