akhauriyash/Code-Regression huggingface dataset:
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
// void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll N = 105;
const ll mm = 1e+18;
void solve()
{
    int n,aa,b;
    cin>>n>>aa>>b;
    int ans=0;
    int a[n];
    rep0(i,n) cin>>a[i];
    rep1(i,n-1){
        ans+=min((a[i]-a[i-1])*aa,b);
    }
    pr(ans);
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    rep1(_i,t){
        //cout<<"Case #"<<_i<<": ";
        solve();
        //nx;
    }
    return 0;
}

Measured memory_bytes: 4400
#include <stdio.h>

int main()
{
  int nq, i, j, m, n, count = 0;
  unsigned long w[64];
  w[0]=1;
  for (i=1; i<64; i++) 
    w[i]=w[i-1]*2;
  char buf[192];
  buf[191]='\0';
  buf[190]='\n';
  char a[64] = {0};
  unsigned long val;
  fgets(buf, 32, stdin);
  char *p = buf;
  for (n=0; *p>='0'; p++)  n = n * 10 + *p - '0';
  char masks[n][65];
  for (i=0;i<n;i++) for(j=0;j<65;j++) masks[i][j]=0;

  for (i=0; i<n; i++) {
    fgets(buf, 190, stdin);
    p = buf;
    masks[i][0]=0;
    j=0;
    for (m=0; *p!='\n'; p++) {
      if (*p == ' ') {
	masks[i][++j] = *(++p)-'0';
      } else {
	masks[i][j] = masks[i][j] * 10 + *p - '0';
      }
    }
  }

  p = fgets(buf, 32, stdin);
  for (nq=0; *p>='0'; p++)  nq = nq * 10 + *p - '0';
  while (nq-->0) {
    fgets(buf, 192, stdin);
    switch (buf[0]-'0') {
    case 0: // test(i)
      i = (buf[3]=='\n') ? buf[2]-'0' : (buf[2]-'0')*10+buf[3]-'0';
      fputs(a[i]?"1\n":"0\n", stdout);
      break;
    case 1: // set(m)
      m = (buf[3]=='\n') ? buf[2]-'0' : (buf[2]-'0')*10+buf[3]-'0';
      for (i=1; i<=masks[m][0]; i++)	a[(int)masks[m][i]]=1;
      break;
    case 2: // clear(m)
      m = (buf[3]=='\n') ? buf[2]-'0' : (buf[2]-'0')*10+buf[3]-'0';
      for (i=1; i<=masks[m][0]; i++)	a[(int)masks[m][i]]=0;
      break;
    case 3: // flip(m)
      m = (buf[3]=='\n') ? buf[2]-'0' : (buf[2]-'0')*10+buf[3]-'0';
      for (i=1;i<=masks[m][0];i++) {
	if (a[(int)masks[m][i]]) a[(int)masks[m][i]]=0;
	else a[(int)masks[m][i]]=1;
      }
      break;
    case 4: // all(m)
      m = (buf[3]=='\n') ? buf[2]-'0' : (buf[2]-'0')*10+buf[3]-'0';
      for (i=1;i<=masks[m][0];i++) {
	if (a[(int)masks[m][i]]==0) {
	  fputs("0\n", stdout);
	  break;
	}
      }
      if (i==masks[m][0]+1) fputs("1\n", stdout);
      break;
    case 5: // any(m)
      m = (buf[3]=='\n') ? buf[2]-'0' : (buf[2]-'0')*10+buf[3]-'0';
      for (i=1;i<=masks[m][0];i++) {
	if (a[(int)masks[m][i]]) {
	  fputs("1\n", stdout);
	  break;
	}
      }
      if (i==masks[m][0]+1) fputs("0\n", stdout);
      break;
    case 6: // none(m)
      m = (buf[3]=='\n') ? buf[2]-'0' : (buf[2]-'0')*10+buf[3]-'0';
      for (i=1;i<=masks[m][0];i++) {
	if (a[(int)masks[m][i]]) {
	  fputs("0\n", stdout);
	  break;
	}
      }
      if (i==masks[m][0]+1)  fputs("1\n", stdout);
      break;
    case 7: // count(m)
      m = (buf[3]=='\n') ? buf[2]-'0' : (buf[2]-'0')*10+buf[3]-'0';
      count = 0;
      for (i=1; i<=masks[m][0]; i++)
	if (a[(int)masks[m][i]]) count++;

      if (count==0) {
	fputs("0\n", stdout);
      } else {
	for (j=189; count>0; j--, count/=10)   buf[j] = '0' + (count%10);
	fputs(buf+j+1, stdout);
      }
      break;
    case 8: // val(m)
      m = (buf[3]=='\n') ? buf[2]-'0' : (buf[2]-'0')*10+buf[3]-'0';
      val = 0;
      for (i=1;i<=masks[m][0];i++) {
	if (a[(int)masks[m][i]])
	  val += w[(int)masks[m][i]];
      }
      if (val==0) {
	fputs("0\n", stdout);
      } else {
	for (j=189; val>0; j--, val/=10)   buf[j] = '0' + (val%10);
	fputs(buf+j+1, stdout);
      }
    }
  }
  return 0;
}



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

int bubbleSort(int A[], int N)
{
    int sw = 0;
    bool flag = 1;
    for (int i = 0; flag; i++)
    {
        flag = 0;
        for (int j = N - 1; j >= i + 1; j--)
        {
            if (A[j] < A[j - 1])
            {
                swap(A[j], A[j - 1]);
                flag = 1;
                sw++;
            }
        }
    }
    return sw;
}

int main()
{
    int A[100], N, sw;
    cin >> N;
    for (int i = 0; i < N; i++)
        cin >> A[i];

    sw = bubbleSort(A, N);

    for (int i = 0; i < N; i++)
    {
        if (i)
            cout << " ";
        cout << A[i];
    }

    cout << endl;
    cout << sw << endl;
    return 0;
}


Measured memory_bytes: 3100
import sys
input=sys.stdin.readline
from collections import deque
n,q=map(int,input().split())
Edges=[[] for _ in range(n)]
for _ in range(n-1):
    a,b=map(int,input().split())
    a-=1; b-=1
    Edges[a].append(b)
    Edges[b].append(a)
Q=[0]*n
for _ in range(q):
    p,x=map(int,input().split())
    Q[p-1]+=x
Ans=[0]*n
q=deque([0])
Ans[0]=Q[0]
Visited=[False]*n
Visited[0]=True
while q:
    fr=q.pop()
    for to in Edges[fr]:
        if Visited[to]:
            continue
        Ans[to]=Ans[fr]+Q[to]
        Visited[to]=True
        q.append(to)
print(*Ans)

Measured memory_bytes: 95380
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define bg begin()
#define en end()
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

#define pr_arr(name, a, b) \
  for (int i = (a); i < (b); i++) { \
    for (int j = (a); j < (b); j++) {\
      if (j > (a)) printf(" "); \
      printf("%lld", name[i][j]); \
    }\
    printf("\n");\
  }\

#define YES puts("YES")
#define NO  puts("NO")
#define Yes puts("Yes")
#define No  puts("No")

using namespace std;

typedef long long ll;

int ans;
char S[4];

int main(void) {
    scanf("%s", S);
    string x = S;

    if (x=="SUN") ans = 7;
    else if (x=="MON") ans = 6;
    else if (x=="TUE") ans = 5;
    else if (x=="WED") ans = 4;
    else if (x=="THU") ans = 3;
    else if (x=="FRI") ans = 2;
    else if (x=="SAT") ans = 1;
     
   

  
    printf("%d\n", ans);

	return 0;
}


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

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

    for(ll i=m/n; i>0; i--){
        if(m%i==0 && m/i>=n){
            cout << i << endl;
            return 0;
        }
    }


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

int main(){
  ll n,m;
  cin>>n>>m;
  P p[111111];
  for(int i=0;i<n;i++){
    ll a,b;
    cin>>a>>b;
    p[i]=P(a,b);
  }
  sort(p,p+n);

  ll ans=0;
  ll cnt=0;
  for(int i=0;i<n;i++){
    ll k=min(m-cnt,p[i].se);
    ans+=k*p[i].fi;
    cnt+=k;
    if(cnt>=m)break;
  }

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


Measured memory_bytes: 1920
class RollingHash():
    def __init__(self, string):
        self.n = len(string)
        self.BASE = 1234
        self.MOD = (1 << 61) - 1
        self.hash = [0] * (self.n + 1)
        self.pow = [1] * (self.n + 1)
        
        for i, char in enumerate(string):
            self.hash[i+1] = (self.hash[i] + ord(char)) * self.BASE % self.MOD
            self.pow[i+1] = (self.pow[i] * self.BASE) % self.MOD
            
    def get_hash(self, l, r):
        res = (self.hash[r] - self.hash[l] * self.pow[r-l]) % self.MOD
        return res
      
    def get_lcp(self, l1, r1, l2, r2):
        ng = min(r1 - l1, r2 - l2) + 1
        ok = 0
        while abs(ok - ng) > 1:
            mid = (ok + ng) // 2
            if self.get_hash(l1, l1 + mid) == self.get_hash(l2, l2 + mid):
                ok = mid
            else:
                ng = mid
        return ok
        
n = int(input())
s = input()

rh = RollingHash(s)

s = 0
def solve(mid):
    length = mid
    set_ = set()
    for l in range(n):
        # [l, l + length), [l + length, l + 2*length)
        if l + 2*length > n:
            break
        set_.add(rh.get_hash(l, l + length))
        tmp = rh.get_hash(l + length, l + 2*length)
        if tmp in set_:
            ans = length
            return True
    return False
  
ok = 0
ng = n//2 + 1
while abs(ng - ok) > 1:
    mid = (ok + ng) // 2
    if solve(mid):
        ok = mid
    else:
        ng = mid
print(ok)

Measured memory_bytes: 46556
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 100005
#define INF 1000000000000005LL
#define ALL 1000000000000000LL

using namespace std;
typedef long long int ll;
typedef pair <ll,ll> P;

ll n;
int N;
ll K;
struct edge{ll to,cost;};
vector<edge> G[2][SIZE];//1:円 2:す
ll d[2][SIZE];

void dijkstra(ll s,int c){
	priority_queue<P, vector<P>, greater<P>> que;
	fill(d[c],d[c]+n,INF);
	d[c][s] = 0;
	que.push(P(0,s));

	while(!que.empty()){
		P p = que.top();que.pop();
		ll v = p.second;
		if(d[c][v] < p.first)continue;
		for(ll i=0;i<G[c][v].size();i++){
			edge e = G[c][v][i];
			if(d[c][e.to] > d[c][v] + e.cost){
				d[c][e.to] = d[c][v] + e.cost;
				que.push(P(d[c][e.to],e.to));
			}
		}
	}
}
ll dat[1<<19];

//配列、木:0オリジン
//n_:元の数列の要素数
//n:修正後の配列要素数 木のサイズ:2*n-1
void init(int n_){
	N=1;
	while(N<n_)N*=2;
	for(int i=0;i<2*N-1;i++)dat[i]=INF;
}

void update(int i,ll x){
	i += N-1;
	dat[i] = x;
	while(i>0){
		i = (i-1)/2;
		dat[i] = min(dat[i*2+1],dat[i*2+2]);
	}
}

//[a,b)のmin 節点k[l,r)について調べる
ll find(int a,int b,int k,int l,int r){
	if(r<=a || b<=l){
		return INF;
	}else if(a<=l && r<=b){
		return dat[k];
	}else{
		ll v1 = find(a,b,2*k+1,l,(l+r)/2);
		ll v2 = find(a,b,2*k+2,(l+r)/2,r);
		return min(v1,v2);
	}
}

int main()
{
	ll s,t;
	int m;
	scanf("%lld%d%lld%lld",&n,&m,&s,&t);
	ll u,v;
	ll a,b;
	for(int i=0;i<m;i++){
		scanf("%lld%lld%lld%lld",&u,&v,&a,&b);
		G[0][u].push_back((edge){v,a});
		G[0][v].push_back((edge){u,a});
		G[1][u].push_back((edge){v,b});
		G[1][v].push_back((edge){u,b});
	}
	n++;
	dijkstra(s,0);
	dijkstra(t,1);
	//d[0][i]+d[1][i] : コスト (1:n)
	N = (int)n;
	init(N);
	for(int i=1;i<=(int)(n-1);i++){
		//printf("%lld,",d[0][i]+d[1][i]);
		update(i-1,d[0][i]+d[1][i]);
	}
	ll cost = find(0,N,0,0,N);
	printf("%lld\n",ALL-cost);
	for(int i=0;i<(int)(n-2);i++){
		update(i,INF);
		ll cost = find(0,N,0,0,N);
		printf("%lld\n",ALL-cost);
	}

	return 0;
}


Measured memory_bytes: 22468
import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

n = int(input())
t = [0] * n 
for i in range(n):
    t[i] = int(input())

ans = t[0]
for i in range(1, n):
    ans = lcm(ans, t[i])

print(ans)



Measured memory_bytes: 62852
#include<iostream>
using namespace std;
#include<vector>
#include<set>
#include<map>
#define int long long int
#define mod 1000000007
bool prime(int x)
{
	if(x==2||x==3||x==5)
	   return true;
	if(x==1||x==4)
	   return false;
	if(x%2==0||x%3==0||x%5==0)
	    return false;
	for(int i=7;i*i<=x;i++)
	{
		if(x%i==0)
		   return false;
	}
	return true;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    int n;
    cin>>n;
    vector<int> v(n+1);
    int j;
    for(j=0;j<=n;j++)
    {
		v[j]=0;
	}
	for(j=1;j<=n;j++)
	{
		int x=j;
		int i;
		int y=x;
		for(i=1;i<=y;i++)
		{
			if(prime(i))
			{
				while(x%i==0)
				{
					v[i]++;
					x=x/i;
				}
			}
		}
	}
	int answer=1;
	for(int i=0;i<=n;i++)
	{
		answer=answer*(v[i]+1);
		answer=answer%mod;
	}
	cout<<answer<<endl;
}	



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

void solve(long long N, long long X){
    ll ret = N;
    ll a = max(N-X,X);
    ll b = min(N-X,X);
    while(1){
        ll q = a/b;
        ll r = a%b;
        ret += 2 * (a/b ) * b;
        if (r==0){
            ret -= b;
            break;
        }
        a = b;
        b = r;
    }
    printf("%lld\n",ret);
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long X;
    scanf("%lld",&X);
    solve(N, X);
    return 0;
}


Measured memory_bytes: 256
N = int(input())
NList = []
for i in range(N):
    NList.append(input())
    
NList.sort()

RList = []
R = 1

tmp = 1

for i in range(1, N):
    if NList[i] == NList[i - 1]:
        tmp += 1
    else:
        if R < tmp:
            R = tmp
            RList = [NList[i - 1]]
        elif R == tmp:
            RList.append(NList[i - 1])
        
        tmp = 1

if R < tmp:
    R = tmp
    RList = [NList[N - 1]]
elif R == tmp:
    RList.append(NList[N - 1])
    
for i in range(len(RList)):
    print(RList[i])

Measured memory_bytes: 20800
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <string>
#include <complex>
 
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <cstring>
 
#define REP(i,e) for(int i=0;i<(int)(e);i++)
#define FOR(i,b,e) for(int i=(int)(b);i<(int)(e);i++)
#define ALL(c) (c).begin(), (c).end()
#define EACH(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define RALL(c) (c).rbegin(), (c).rend()
#define ALLA(a,n) ((a)+0), ((a)+n)
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<string> vstring;
typedef vector<double> vdouble;
 
template<class T>void pp(T v,int n){ REP(i,n)cout<<v[i]<< ' ' ; cout << endl; }
template<class T>void pp(T v){ EACH(it,v) cout << *it << ' ' ; cout << endl;  }
template<class T>T& ls(T& a,T b){ if(b<a) a=b; return a; }
template<class T>T& gs(T& a,T b){ if(b>a) a=b; return a; }
inline ll to_i(const string& s){ll n;sscanf(s.c_str(),"%lld",&n);return n;}
inline string to_s(ll n){char buf[32];sprintf(buf,"%lld",n);return string(buf);}

int main() {
  int n;
  while (cin >> n) {
    vint v(n);
    REP(i,n)cin >> v[i];
    int result = 1 << 20;
    FOR(t,1,n) {
      int a = accumulate(v.begin(), v.begin() + t, 0);
      int b = accumulate(v.begin() + t, v.end(), 0);
      ls(result, abs(a - b));
    }

    cout << result << endl;
  }
}


Measured memory_bytes: 888
import sys
from string import digits

def main():
    n, s = sys.stdin.read().split()

    cnt = 0
    for i in digits:
        x = s.find(i)
        if x == -1:
            continue
        for j in digits:
            y = s.find(j, x + 1)
            if y == -1:
                continue
            for k in digits:
                z = s.find(k, y + 1)
                if z == -1:
                    continue
                cnt += 1

    print(cnt)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3772
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!(
        n : i32,
        y : i32,
    );
    let mut ans = None;
    'outer: for i in 0..n + 1 {
        for j in 0..n - i + 1 {
            let k = n - i - j;
            if i * 10000 + j * 5000 + k * 1000 == y {
                ans = Some((i, j, k));
                break 'outer;
            }
        }
    }
    let (x, y, z) = ans.unwrap_or((-1, -1, -1));
    println!("{} {} {}", x, y, z);
}

Measured memory_bytes: 4352
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (int)1e9 + 7;

int main() {
    int n, m; cin >> n >> m;
    vector<int> dp(1 << n, INF);
    dp[0] = 0;
    while (m--) {
        int a, b; cin >> a >> b;
        int mask = 0;
        while (b--) {
            int c; cin >> c; c--;
            mask |= 1 << c;
        }
        for (int s = 0; s < 1 << n; s++) if (dp[s] != INF) {
            chmin(dp[s | mask], dp[s] + a);
        }
    }
    cout << (dp.back() == INF ? -1 : dp.back()) << endl;
    return 0;
}

Measured memory_bytes: 256
# coding: UTF-8
# sample code

n = int(input())
nsp = []
for i in range(n):
	v = list(map(str, input().split(' ')))
	nsp.append([v[0], -int(v[1]), i+1])

nsp.sort()

for i in range(n):
	print(nsp[i][2])

Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
  int i,A[100],n,minj,j,count=0,B;

  scanf("%d",&n);

  for(i=0;i<n;i++)
    {
      scanf("%d",&A[i]);
    }




  for(i=0;i<n;i++)
    {
      minj=i;
      for(j=i;j<n;j++)
	{
	  if(A[j]<A[minj])
	    {
	      minj=j;
	    }
	}
      if(minj>i)
	{
	  B=A[i];
	  A[i]=A[minj];
	  A[minj]=B;
	  count++;
     
	}
    }

  for(i=0;i<n-1;i++)
    {
      printf("%d ",A[i]);
    }
  printf("%d\n%d\n",A[n-1],count);

  return 0;
}

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

int main() {
	//cout<<"GfG!";
	long long int n;
	cin>>n;
	long long int arr[n],i=0,sum=0,answer=0,mod=pow(10,9)+7;
	while(i<n)
	{
	    cin>>arr[i];
	    sum+=arr[i];
	    i++;
	}
	i=0;
	while(i<n-1)
	{
	    long long int c=sum-arr[i];
	    c%=mod;
	    answer=(answer+(arr[i]*c)%mod)%mod;
	    sum-=arr[i];
	    i++;
	}
	cout<<answer<<endl;
	return 0;
}

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

using namespace std;

int main(){
    int N;
    int odd[100001];
    int even[100001];
    int v[100001];
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> v[i];
    }

    for(int i = 1;i < N; i+=2){
        odd[v[i]]++;
        even[v[i^1]]++;
    }

    int omax = 0,emax = 0, omax2 = 0, emax2 = 0;
    for(int i = 0;i < 100001; i++){
        if(omax < odd[i]){
            omax = odd[i];
            omax2 = i;
        }
        if(emax < even[i]){
            emax = even[i];
            emax2 = i;
        }
    }

    if(omax2 != emax2){
        cout << (N -omax -emax) << endl;
    }else{
        int osec = 0, esec = 0;
        for(int i = 0;i < 100001; i++){
            //なるほど、ほんとの最大値は引っかからないようにif文を設定して最大値をもう一度求めることで二番目の最大値を求めれるというわけか
            if(osec <= odd[i] && i!= omax2){
                osec = odd[i];
            }
            if(esec < even[i] && i != emax2){
                esec = even[i];
            }
        }
        cout << min((N-omax-esec),(N-emax-osec));
    }
    return 0;
}

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


int main()
{
	int n, m, x, y, xm = -100, ym = 100, xn, yn;
	cin >> n >> m >> x >> y;
	for (int i = 0; i < n; i++) {
		cin >> xn;
		if (xn > xm) {
			xm = xn;
		}
	}
	for (int i = 0; i < m; i++) {
		cin >> yn;
		if (yn < ym) {
			ym = yn;
		}
	}
	if (xm < ym && x < xm&&ym < y) {
		cout << "No War";
	}
	else {
		cout << "War";
	}

		
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<=n;i++)
typedef long long ll;
typedef vector<int> vec;
int main(){
  int ans[4];
  int n,m,s,c;
  cin>>n>>m;
  rep(i,4)ans[i]=10;

  rep(i,m){
    cin>>s>>c;
    if(ans[s]==10||ans[s]==c)ans[s]=c;
    else{cout<<-1; return 0;}
  }
  if(n!=1&&ans[1]==0){cout<<-1;return 0;}
  rep(i,n)if(ans[i]==10)ans[i]=0;
  if(n!=1&&ans[1]==0)ans[1]++;
  
  rep(i,n)cout<<ans[i];

}

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


int main() {
  string s;
  cin>>s;
  ll mod=1e9+7,sum;
  ll n=s.size();
  ll dp[1000000][13];
  dp[0][0]=1;
  
  for(ll i=0; i<n; i++){
    ll c=0;
    if(s[i]=='?'){
      c=-1;
    }else{
      c=s[i]-'0';
    }
    for(ll j=0; j<10; j++){
      
      if(c!=-1&&c!=j)
        continue;
      for(ll k=0; k<13; k++){
        dp[i+1][(k*10+j)%13]+=dp[i][k];
      }
    }
    for(ll j=0; j<13; j++)
        dp[i+1][j]%=mod;
  }
     sum=dp[n][5]; 
   cout<<sum<<endl; 
  
}

Measured memory_bytes: 12416
// Undone
#include <bits/stdc++.h>
using namespace std;
signed main() {
  int N, W, D;
  while (cin>>N>>W>>D, N+W+D) {
    vector<pair<int, int>> v;
    v.push_back(make_pair(W, D));
    for (int i = 0; i < N; i++) {
      int p, s;
      cin>>p>>s;
      p--;
      int w = v[p].first, d = v[p].second;
      while (s > w*2+d*2) s -= w*2+d*2;
      pair<int,int> p1, p2;
      if (s < w) {
        p1 = make_pair(s, d);
        p2 = make_pair(w-s, d);
      } else if (s < w + d) {
        s -= w;
        p1 = make_pair(w, s);
        p2 = make_pair(w, d-s);
      } else if (s < 2*w+d) {
        s -= w+d;
        p1 = make_pair(s, d);
        p2 = make_pair(w-s, d);
      } else if (s < 2*w+2*d) {
        s -= 2*w+d;
        p1 = make_pair(w, s);
        p2 = make_pair(w, d-s);
      }
      v.erase(v.begin() + p);
      if (p1.first*p1.second > p2.first*p2.second) swap(p1, p2);
      v.push_back(p1);
      v.push_back(p2);
    }

    vector<int> ans(v.size());
    for (int i = 0; i < v.size(); i++) {
      ans[i] = v[i].first*v[i].second;
    }
    sort(ans.begin(), ans.end());
    for (int i = 0; i < v.size(); i++) {
      if (i) cout<<" ";
      cout << ans[i];
    }
    cout << endl;
  }
}




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


const ll modi = 1e9+7;
ll binpow(ll a,ll b){
	ll res  =1;
	while(b>0){
		if(b&1)
			res = res*a%modi;
		a= a*a%modi;
		b>>=1;
	}
	return res;
}

int main(){
	ll n,k;
	cin >> n >>k;
	ll dp[k+1];
	memset(dp,0,sizeof(dp));
	for(ll i =k;i>0;--i){
		ll to_make = k/i;
		dp[i] = binpow(to_make,n);
		for(int j = 2;i*j<=k;j++){
			dp[i]-=dp[i*j];
		}
	}

	ll ans =0;
	for(int i =1;i<=k;i++){
		ans = (ans + i*dp[i]%modi)%modi;
	}
	cout << ans << endl;

}

Measured memory_bytes: 4268
#include<bits/stdc++.h>
#define _USE_MATH_DEFINES
using namespace std;
 
#define ll long long int
#define pb push_back
#define rep(i , j , n) for(ll i = j ; i < n ; i++)
#define per(i , j , n) for(ll i = j ; i >= n ; i--)
#define all(x) x.begin(), x.end()
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vll;

int main(){
    ll a[5],ans;
    rep(i,0,5){
        cin >> a[i];
        if(a[i] == 0) ans = i + 1;

    }
    cout << ans;
}

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

int main()
{
	int ans = 0, n;
	cin >> n;
	for (int i = 0; i < 100; ++i)
	{
		for (int j = 0; j < 100; ++j)
		{
			if (i * 4 + j * 7 == n)
			{
				++ans;
			}
		}
	}
	cout << ((ans == 0)?"No":"Yes") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <map>
using namespace std;
typedef long long LL;
const int maxn=2e5+10;

map<LL,int> rec;
int n,a[maxn];
LL s,ans;

int main()
{
	scanf("%d",&n);
	rec[0]=1;ans=0ll;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		s+=(LL)a[i];
		ans+=(LL)rec[s];
		rec[s]++;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 13568
global N, M, Q, T
N, M, Q = map(int, input().split())
T = []
for i in range(Q):
    T.append(list(map(int, input().split())))

def score(lists):
    tmp = 0
    for i in T:
        if lists[i[1] - 1] - lists[i[0] - 1] == i[2]:
            tmp += i[3]
    return tmp
        
def make_lists(lists=[], s=0, ans=0, times=0):
    if times == N:
        return score(lists)

    for i in range(s, M):
        ans = max(ans, make_lists(lists + [i], i, ans, times + 1))
    return ans
        
print(make_lists())


Measured memory_bytes: 8928
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//CODE

void solve(void)
{
  string str;
  cin>>str;
  cout<<str[0]<<(int)(str.size()-2)<<str[str.size()-1]<<endl;
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


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

const int maxn=1e6+7;
int main(){
    int n,d,x;
    scanf("%d %d %d",&n,&d,&x);
    for(int i=0;i<n;i++){
        int val;scanf("%d",&val);
        x++;
        x+=(d-1)/val;
    }
    printf("%d\n",x);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef long double ld;
const ld pi = 4*atan((ld)1);
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll nax = 2e5 + 5;

ll n, a[nax];

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	cin >> n;
	for(ll i = 1; i <= n; i++){
		cin >> a[i];
	}
	ll maxi = -inf;
	ll ans = 0;
	for(ll i = 1; i <= n; i++){
		maxi = max(maxi, a[i]);
		ans += maxi - a[i];
	}
	cout << ans << '\n';
}



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

using namespace std;

static inline int in(){ int x; scanf("%d", &x); return x; }

int main()
{
  int n;
  while (n = in()){
    int count = 0;
    for (int i = 0; i < n; i++){
      for (int j = 0; j < n; j++){
        if (2 * n + i * (i + 1) == j * (j + 1)){
          count++;
          break;
        }
      }
    }
    printf("%d\n", count);
  }

  return 0;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - Next Alphabet
            var s = Console.ReadLine();
            var C = s[0];
            char before = 'a';

            for(char c = 'b'; c <= 'z'; c++)
            {
                if (before == C)
                {
                    Console.WriteLine(c);
                    return;
                }
                else
                {
                    before = c;
                }
            }
        }
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 3000005
#define endl "\n"
#define mod 998244353
#define PI 3.141592653589793
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
ll n,s,ar[3005],str[10005]; ll dp[3001][3001];
ll maxval(ll i,ll s){
    if(s<0) return 0;
    if(s==0){
        return str[i];
    }
    if(i>n) return 0;

    if(dp[i][s]!=-1){
        return dp[i][s];
    }

    ll a,b;
    a=2*maxval(i+1,s);
    b=maxval(i+1,s-ar[i])%mod;
    return dp[i][s]=(a+b)%mod;
}
int main(){

    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
        
    ll i,j,k,l;
    cin>>n>>s;
    for(i=0;i<=n+2;i++){
        str[i]=power(2,n+1-i,mod);
    }
    for(i=1;i<=n;i++){
        cin>>ar[i];
    }

    memset(dp,-1,sizeof(dp));
    ll an=maxval(1,s);
    cout<<an;
    return 0;   
}

Measured memory_bytes: 74200
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

int main(){
    int h,w,k;
    cin >> h >> w >> k;
    vector<string> maze(h);
    vector<vector<int>> ans(h,vector<int>(w,0));
    rep(i,h) cin >> maze[i];
    vector<int> cnt(h,0);
    rep(i,h){
        rep(j,w) cnt[i] += (maze[i][j]=='#');
    }
    int id = 0;
    int now = 1;
    rep(i,h){
        if(cnt[i]!=0){id = i; break;}
    }
    for(int i=id;i<h;i++){
        bool first = true;
        if(cnt[i]==0){
            rep(j,w) ans[i][j] = ans[i-1][j];
        }else{
            rep(j,w){
                if(maze[i][j]=='#'&&first){
                    first = false;
                }else if(maze[i][j]=='#'){
                    ++now;
                }
                ans[i][j] = now;
            }
            ++now;
        }
    }
    for(int i=id-1;i>=0;i--){
        rep(j,w) ans[i][j] = ans[i+1][j];
    }
    rep(i,h){
        rep(j,w) cout << ans[i][j] << " ";
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 4152
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <cmath>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#include <iomanip>

#define MOD (1000000007)
using namespace std;

typedef long long ll;

typedef tuple<ll, ll> tup; 


int main() {

    ll X;
    cin >> X;

    for(int A = 0;; A++) {
        for(int B = A;; B--) {
            ll tmp = pow(A, 5) - pow(B, 5);

            if(tmp > X) break;
            if(tmp == X) {
                cout << A << " " << B << endl;
                return 0;
            }
        }
    }


    return 0;
}


Measured memory_bytes: 4100
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a0,l;
		boolean flag = true;
		ArrayList<Integer> al;
		while(true) {
			a0 = sc.nextInt();
			l = sc.nextInt();
			if(l==0) {break;}
			
			al = new ArrayList<>();
			flag = true;
			al.add(a0);
			do {
					al.add(calcNext(al.get(al.size()-1), l));
				for(int i=0; i<al.size()-1; i++) {
					if(al.get(i).equals(al.get(al.size()-1))) {
						System.out.println(i + " " + al.get(i) + " " + (al.size()-1-i));
						flag = false;
						break;
					}
				}
			}while(flag);
			
		}
		sc.close();
	}
	
	public static int calcNext(int n,int l) {
//		int length = (int)Math.log10(n-1) +1 ;
		String str = "" + n;
		while(str.length() != l) {
			str = "0" + str;
		}
		char[] c = str.toCharArray();

		Arrays.sort(c);
		
		n=0;
		for(int i=0;i<c.length;i++) {
			n-=Integer.parseInt(""+c[i]) * Math.pow(10, c.length - i - 1);
		}
		for(int j=0;j<c.length;j++) {
			n+=Integer.parseInt(""+c[j]) * Math.pow(10, j);
		}
		
		return n;
	}

}



Measured memory_bytes: 29712
#include <bits/stdc++.h>
using namespace std;
long long n,t;
int main(){
    scanf("%lld",&n);
    if(n%2LL)printf("0");
    else{
        n>>=1;
        while(n){
            n/=5;
            t+=n;
        }
        printf("%lld",t);
    }
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func rScan() []rune {
	return []rune(Scan())
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func mod(x, d int) int {
	x %= d
	if x < 0 {
		x += d
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := -int(1e+18)
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := int(1e+18)
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}
func fSum(a []float64) float64 {
	x := 0.
	for _, v := range a {
		x += v
	}
	return x
}
func bPrint(f bool, x string, y string) {
	if f {
		fmt.Println(x)
	} else {
		fmt.Println(y)
	}
}
func iSSPrint(x []int) {
	fmt.Println(strings.Trim(fmt.Sprint(x), "[]"))
}

var lp1 int = 1000000007
var lp2 int = 998244353

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, lp1)
	sc.Split(bufio.ScanWords)
	n := iScan()
	a := iSScan(n - 1)
	e := make([][]int, n)
	for i, v := range a {
		e[v-1] = append(e[v-1], i+1)
	}
	d := make([]int, n)
	var dfs func(s int)
	dfs = func(s int) {
		for _, v := range e[s] {
			dfs(v)
		}
		x := make([]int, len(e[s])+1)
		for i, v := range e[s] {
			x[i+1] = d[v]
		}
		sort.Ints(x)
		for i := 1; i < len(x); i++ {
			x[i] = larger(x[i-1], x[i]) + 1
		}
		d[s] = x[len(x)-1]
	}
	dfs(0)
	fmt.Println(d[0])
}


Measured memory_bytes: 34952
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);};};
const int MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<62;

bool isok(int n){
    set<int> s;
    int add=0;
    for(int i=0;;i++){
        add+=3;
        s.insert(add);
        if(add>100000)break;
        add+=i;
    }
    if(s.find(n)==s.end()){
        return 0;
    }else {
        return 1;
    }
}

int main(void) {

    int n;
    cin>>n;
    if(n==1){
        cout<<"Yes"<<endl;
        cout<<2<<endl;
        cout<<1<<" "<<1<<endl;
        cout<<1<<" "<<1<<endl;
        return 0;
    }
    if(!isok(n)){
        cout<<"No"<<endl;
        return 0;
    }else {
        cout<<"Yes"<<endl;
    }
    vvi v;
    vector<int> a{1,2};
    v.push_back(a);
    vector<int> b{2,3};
    v.push_back(b);
    vector<int> c{3,1};
    v.push_back(c);

    int tate=0;
    int yoko=2;
    for(int i=4;i<=n;i++){
        if(v[0].size()==v[v.size()-1].size()){
            vector<int> tmp(1,i);
            v.push_back(tmp);
            yoko++;
        } else {
            v[yoko].push_back(i);
        }
        v[tate].push_back(i);
        tate++;
        if(tate == yoko){
            tate=0;
        }
    }
    cout<<(int)v.size()<<endl;
    for(int i=0;i<v.size();i++){
        cout<<(int)v[i].size();
        for(int j=0;j<v[i].size();j++){
            cout<<" "<<v[i][j];
        }
        cout<<endl;
    }

}


Measured memory_bytes: 2304
package main

import "fmt"

func getMax(nums []int) (max int) {
	max = nums[0]
	for i := 0; i < len(nums); i++ {
		if nums[i] > max {
			max = nums[i]
		}
	}
	return
}

func getMin(nums []int) (min int) {
	min = nums[0]
	for i := 0; i < len(nums); i++ {
		if nums[i] < min {
			min = nums[i]
		}
	}
	return
}

func main() {
	var N, M, X, Y int
	fmt.Scan(&N, &M, &X, &Y)
	lx := make([]int, N)
	ly := make([]int, M)
	for i := 0; i < N; i++ {
		fmt.Scan(&lx[i])
	}
	for i := 0; i < M; i++ {
		fmt.Scan(&ly[i])
	}
	if getMax(lx) < Y && X < getMin(ly) && getMax(lx) < getMin(ly) {
		fmt.Println("No War")
	} else {
		fmt.Println("War")
	}
}


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

int ans = 0;
int w,h;
int map[100][100] ={};


void search(int y,int x){

  //  cout << "search"<< y <<" " << x << endl;
  map[y][x] = 0;

  for(int dy = -1 ; dy <= 1 ; dy++){
    for(int dx = -1 ; dx <= 1 ; dx++){
      int nx = x + dx, ny = y + dy;
      if(nx >= 0 && ny >= 0 && nx < w && ny < h && map[ny][nx] == 1 ){
	search(ny,nx);
      }
    }
  }
  /*
    if( map[y][x] == 0 ){
    //テ・ツ渉ウテァツォツッ
    if(x+1 == w){
      //テヲツ慊?・ツセツ?
      if(y+1 == h){
      }
      //テヲツ慊?」ツつづ、ツクツ凝」ツ?ョテヲツョツオ
      else{
	search(y+1,x);
    }else{
      search(y,x+1);
    }
  }
  */
}


int main(){

  while(1){

    ans = 0;
    cin >> w >> h ;

    if(w == 0 && h == 0) break;

    for(int i = 0 ; i < h ; i++){
      for(int j = 0 ; j < w ; j++){
	cin >> map[i][j];
      }
    }
    //map テ・ツ?コテ・ツ環?
    /*
    for(int i = 0 ; i < h ; i++){
      for(int j = 0 ; j < w ; j++){
	cout << map[i][j];
      }
      cout << endl;
    }
    //    cout << endl;
    */
    for(int i = 0 ; i < h ; i++){
      for(int j = 0 ; j < w ; j++){
	if(map[i][j] == 1){
	  ans++;
	  search(i,j);
	}
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1364
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)



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

	if (n <= m / 2) {
		sum1 = n + ((m - n * 2) / 4);
	} else {
		sum1 = m / 2;
	}
	cout << sum1 << endl;
	return 0;
}




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

A = [None] * N
A[0] = B[0]
for i in range(1, N):
    A[i] = B[i - 1]
for i in range(N - 1):
    if B[i] < max(A[i],A[i + 1]):
        A[i] = B[i]
ans = sum(A)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int q;
    cin >> q;
    long long flag = 0;
    string s1, s2;
    for(int i = 0; i < q; i++){
        int t;
        cin >> t;
        if(t == 1) flag += 1;
        else if(t == 2){
            int f;
            string c;
            cin >> f >> c;
            if(flag % 2 == 1){
                if(f == 1) s2 = s2 + c;
                else s1 = c + s1;
            }
            else if(flag % 2 == 0){
                if(f == 1) s1 = c + s1;
                else s2 = s2 + c;
            }
        }
    }
    if(flag % 2 == 1){
        reverse(s.begin(), s.end());
        reverse(s1.begin(), s1.end());
        reverse(s2.begin(), s2.end());
        cout << s2 << s << s1 << endl;
    }
    else cout << s1 << s << s2 << endl;
}

Measured memory_bytes: 1160
import numpy as np
from numba import jit 
N , K = map(int,input().split())
Lum = np.array(list(map(int,input().split())))

@jit("i8,i8,i8[:]")
def fn(N,K,A):
    K1 = min(K,41)
    for i1 in range(K1):
        B = np.zeros(N,dtype=np.int64)
        for i in range(N):
            l = max(0,i-A[i])
            r = min(N-1,i+A[i])
            B[l]+=1
            if r+1<N:
                B[r+1]-=1
        for i in range(1,N):
            B[i]+=B[i-1]
        A = B
    return A

Lum = list(fn(N,K,Lum))
Lum = [str(l) for l in Lum]
Lum=" ".join(Lum)
print(Lum)

Measured memory_bytes: 136004
from itertools import zip_longest

l = list(input()) 
for i in range(8):
    p = ["+"if i & j else"-" for j in[1, 2, 4]]
    p.append("")
    line = "".join([v+o for v,o in zip_longest(l,p)])
    if eval(line) == 7:
        print(line + "=7")
        break


Measured memory_bytes: 38384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <set>
#define lowbit(x) (x&(-x))
#define MAX(a,b) (a<b?b:a)
#define MIN(a,b) (a<b?a:b)
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const int N = 1e5;
const int maxn = 3e5 + 5;
ll mod = 1e9 + 7;

char s[maxn];
int x[maxn], m;
vector<pii> ans;
int main()
{
	scanf("%s", s+1);
	int n = strlen(s+1);
	if (s[n] == '1' || s[1]=='0') printf("-1");
	else
	{
		for (int i = 1; i<n; i++)
		{
			if (s[i] != s[n - i])
			{
				printf("-1");
				return 0;
			}
			if (s[i] == '1')
			{
				x[++m] = i;
			}
		}

		for (int i = 1; i <= m; i++)
		{
			ans.push_back(pii(i, i + 1));
		}
		int cur = m + 2;
		for (int i = 2; i <= m; i++)
		{
			for (int j = 1; j <= x[i] - x[i - 1] - 1; j++)
			{
				ans.push_back(pii(i, cur));
				++cur;
			}
		}
		for (int i = 0; i < n-1; i++)
		{
			printf("%d %d\n", ans[i].first, ans[i].second);
		}
	}
}

Measured memory_bytes: 2804
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<int,int> P;
ll longinf=1ll<<60;
int inf=1<<29;

int N,M,Q;
int cnt[502][502];
int usr[502];
int rui[502][502];
int Qu[502][502];


int main(){
    cin>>N>>M>>Q;
    rep0(i,M){
        ll L,R;
        cin>>L>>R;
        rui[L][R]++;
        rui[L][N+1]--;
        usr[R]++;
        }
        for(int L=1;L<=N;L++){
            for(int R=L;R<=N;R++){
                cnt[L][R]=cnt[L][R-1]+rui[L][R];
            }
        }
        Qu[1][N]=M;
        for(int i=N;i>=2;i--){
            Qu[1][i-1]=Qu[1][i]-usr[i];
        }
        for(int R=N;R>=1;R--){
            for(int L=1;L<=R-1;L++){
                Qu[L+1][R]=Qu[L][R]-cnt[L][R];
            }
        }
        rep0(i,Q){
            int p,q;
            cin>>p>>q;
            cout<<Qu[p][q]<<endl;
        }

    
      return 0;
}

Measured memory_bytes: 3840
#include <iostream>
#include <stdlib.h>
#include <math.h>

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int s = a + b;
	if (s < c) {
		c = s + 1;
	}
	cout << b + c;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    long i = 0;
    long kazu=0,iti=0;
    long a=0,b=0,max=0,min=0;
    cin >> kazu;
    if(kazu==1){
        cin>>iti;
        max=iti;
        min=iti;
        b=iti;
    }
    else{
        cin>>iti;
        max=iti;
        min=iti;
        b=iti;
        for(i=0;i<kazu-1;i++){

           cin >> a;
           b+=a;
           if(a>max)max=a;
           if(a<min)min=a;
        }
    }

    cout << min << ' ' << max << ' '<< b << endl;
}

Measured memory_bytes: 1160
N, K = [int(a) for a in input().split()]
S = "1" + str(input()) + "0"
ans = 0
cnt = 1 if S[1] == "0" else 0
num = 0
l, r = (1, 1)
while r <= N:
    while cnt <= K and r<=N:
        if S[r]=="1" and S[r+1]=="0":
            cnt+=1
        num += 1
        r+=1
    ans = max(num, ans)
    while cnt > K and l<=N:
        num -= 1
        l+=1
        if S[l]=="1" and S[l-1]=="0":
            cnt -= 1
print(ans)


Measured memory_bytes: 3316