akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

void dfs1(vector<vector<pair<int,int>>> &graph, vector<int> &num, vector<int> &used, int node, int &con){
        
        if(used[node]) return ;
        
        used[node] = true;
        
        for(pair<int,int> next : graph[node]){
                dfs1(graph, num, used, next.first, con);
        }
        
        num[con++] = node;
}

void dfs2(vector<vector<pair<int,int>>> &graph, vector<int> &scc, vector<int> &used, int node, int same){
        
        if(used[node]) return ;
        
        used[node] = true;
        
        for(pair<int,int> next : graph[node]){
                dfs2(graph, scc, used, next.first, same);
        }
        
        scc[node] = same;
}

void Strongly_Connected_Components(vector<vector<pair<int,int>>> &graph, vector<int> &scc){
        vector<int>  used(graph.size()), num(graph.size());
        vector<vector<pair<int,int>>> graph2(graph.size());
        int con = 0;
        
        scc.resize(graph.size());
        
        for(int i = 0; i < graph.size(); i++){
                dfs1(graph, num, used, i, con);
        }
        
        for(int i = 0; i < graph.size(); i++){
                for(int j = 0; j < graph[i].size(); j++){
                        graph2[graph[i][j].first].push_back(make_pair(i, graph[i][j].second));
                }
        }
        
        used.clear();
        used.resize(graph.size());
        
        for(int i = (int)graph.size()-1, same = 0; i >= 0; i--){
                if(!used[num[i]]){
                        dfs2(graph2, scc, used, num[i], same);
                        same++;
                }
        }
        
}

signed main(){
        int V, E;
        int Q;
        vector<int> scc;
        vector<vector<pair<int,int>>> graph;
        
        cin>>V>>E;
        
        graph.resize(V);
        
        for(int i = 0; i < E; i++){
                int s, t;
                
                cin>>s>>t;
                
                graph[s].push_back(make_pair(t,0));
        }
        
        Strongly_Connected_Components(graph, scc);
        
        cin>>Q;
        
        for(int i = 0; i < Q; i++){
                int u, v;
                
                cin>>u>>v;
                
                cout<<(scc[u] == scc[v])<<endl;
        }
        
        return 0;
}




Measured memory_bytes: 4932
//#pragma GCC optimize("O3")

/*----------------------------------------------------------------------------------------------------------*/

#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
using namespace std;
#define pb push_back

/*----------------------------------------------------------------------------------------------------------*/
 
#define int  long long int
#define ull unsigned long long int
#define ld long double

/*----------------------------------------------------------------------------------------------------------*/

#define mint map<int,int>
#define vint vector<int>
#define pint pair<int,int>
#define mp make_pair
#define F first
#define S second
 
/*----------------------------------------------------------------------------------------------------------*/
 
#define all(x) x.begin(),x.end()
#define ub upper_bound
#define lb lower_bound
#define bin binary_search

/*----------------------------------------------------------------------------------------------------------*/

#define f(i,a,b) for(int i=a;i<b;i++)
#define rf(i,a,b) for(int i=a;i>b;i--)
 
/*----------------------------------------------------------------------------------------------------------*/
 
#define print1(arr,a,b) for(int i=a;i<b;i++) cout<<arr[i]<<" "; cout<<endl
#define print(arr,a,b)  for(int i=a;i<b;i++) cout<<arr[i]<<endl
#define print2d(dp,r,c) for(int i=0;i<r;i++){for(int j=0;j<c;j++) cout<<dp[i][j]<<" "; cout<<endl;}
 
/*----------------------------------------------------------------------------------------------------------*/

// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void ritik()
{
    ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input999.txt", "r", stdin);
        freopen("output999.txt", "w", stdout);
    #endif
}

 
/*--------------------------------------------FUNCIONS--------------------------------------------------------------*/
 
int power(int x,int y,int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return (res%p);
}
 
int max3(int a,int b,int c)
{
    return max(max(a,b),c);
}

int min3(int a,int b,int c)
{
    return min(min(a,b),c);
}


int nCr(int n, int r)
{
    int x=n-r,y=0,z=1;
    while(y<r)
    {
        z=(z*(x+1))/(y+1);
        x++;y++;
    }
    return z;
}
 
/*-----------------------------------------------write your code here-----------------------------------------------------------*/

const int maxm=60;
const int mod=1e9+7;
const int inf=LLONG_MAX;



void solve()
{
    string s; cin>>s;
    if(s=="ABC") cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;

}



signed main()
{
    ritik();
    int T=1;
    //cin>>T;
    while(T--)
    {
        solve();
    }
}

Measured memory_bytes: 3592
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  string S, T;
  cin >> S >> T;
  T += S;
  cout << T << endl;
  return 0;
}


Measured memory_bytes: 256
/*昇順のバブルソート*/
#include <stdio.h>
#include <stdlib.h>

int main() {
  int flag=1;
  int flag_count =0;
  int key;
  int judge=0;
  int n;
  int i,j;
  int *array;

  scanf("%d",&n);
  array = (int *)malloc(n * sizeof(int));

  for(i=0;i<n;i++) {
    scanf("%d",array+i);
  }
  while(flag == 1)
    {
      judge=0;
      for(i=n-1;i>0;i--) {
	if(array[i] < array[i-1]) {
	  key = array[i-1];
	  array[i-1] = array[i];
	  array[i] = key;
	  judge=1;
	  flag_count++;
	}
      }
      if(judge==0) {
	flag=0;
      }
    }
  for(i=0;i<n-1;i++) {
    printf("%d ",array[i]);
  }
  printf("%d\n%d\n",array[n-1],flag_count);
  
  return 0;
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    int n;
    cin >> n;
    set<char> s;
    while(n--){
        char c;
        cin >> c;
        s.insert(c);
    }
    cout << (s.size() == 3 ? "Three" : "Four") << endl;
}


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
	int K,x;cin>>K>>x;
	if(K*500>=x)puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	string s; cin >> s;
	int n = s.size();
	int cnt = 0;
	int ans = 0;
	bool f = true;

	for (int i = 0; i < n; i++) {
		for (int j = i+1; j < n+1; j++) {

			cnt = 0;
			f = true;

			for (int k = i; k < j; k++) {
				if (s[k] == 'A' || s[k] == 'C' || s[k] == 'G' || s[k] == 'T') {
					cnt++;
				}
				else {
					f = false;
				}
			}

			if (f == true) {
				ans = max(ans, cnt);
			}
		}
	}

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



Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <algorithm>
#include <functional>
#include <utility>
#include <string>
#define typeof(x) __typeof__(x)
#define int long long int
#define mod(x) ((x % MOD) + MOD) % MOD
#define ceil(x,m) ((x)+(m)-1)/(m)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);--i)

#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) UB(c,x)-LB(c,x)
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (s).find(e)!=(s).end()
#define PB push_back
#define MP make_pair
#define vec vector

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

using namespace std;

typedef pair<int,int> P;
struct edge { int to, cost; };

const int INF = 1e18;
const int MOD = 1e9+7;

template<typename T> ostream& operator << (ostream& s, const vector<T>& v) {
   int len = v.size();
   s << "[";
   for (int i = 0; i < len; i++) { s << v[i]; if (i < len - 1) s << " "; }
   s << "]";
   return s;
}

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

int lcm(int x, int y) {
   return x * y / gcd(x, y);
}


signed main()
{
   int n, m;
   string s, t;
   cin >> n >> m >> s >> t;

   int g = gcd(n, m);
   int l = lcm(n, m);
   int k = l / g;

   rep(i, 0, g) {
      if (s[n/g * i] != t[m/g * i]) {
         cout << -1 << endl;
         return 0;
      }
   }

   cout << l << endl;

   return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define pb push_back
#define ers erase
#define ins insert
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
#define kill(x) return cout << x, 0;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;


const ld Pi = 3.14159265359;
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll N = 2e5 + 10;
const ll INF = 1e18;

ll a[N];
int main(){
	IOS;
	ll n;
	for (int i = 0; i < 4; i++){
		cin >> n;
		a[n] ++;
	}
	if (a[1] == 1 && a[4] == 1 && a[7] == 1 && a[9] == 1) kill("YES");
	kill("NO");
	
	
	
	
	return 0;
}






/*
     ,---,           ___                 ,--,
    '  .' \        ,--.'|_             ,--.'|                             ,--,
   /  ;    '.      |  | :,'            |  | :                           ,--.'|    ,---.        ,---,
  :  :       \     :  : ' :            :  : '                 .--.--.   |  |,    '   ,'\   ,-+-. /  |
  :  |   /\   \  .;__,'  /    ,--.--.  |  ' |     ,--.--.    /  /    '  `--'_   /   /   | ,--.'|'   |
  |  :  ' ;.   : |  |   |    /       \ '  | |    /       \  |  :  /`./  ,' ,'| .   ; ,. :|   |  ,"' |
  |  |  ;/  \   \:__,'| :   .--.  .-. ||  | :   .--.  .-. | |  :  ;_    '  | | '   | |: :|   | /  | |
  '  :  | \  \ ,'  '  : |__  \__\/: . .'  : |__  \__\/: . .  \  \    `. |  | : '   | .; :|   | |  | |
  |  |  '  '--'    |  | '.'| ," .--.; ||  | '.'| ," .--.; |   `----.   \'  : |_|   :    ||   | |  |/
  |  :  :          ;  :    ;/  /  ,.  |;  :    ;/  /  ,.  |  /  /`--'  /|  | '.'\   \  / |   | |--'
  |  | ,'          |  ,   /;  :   .'   \  ,   /;  :   .'   \'--'.     / ;  :    ;`----'  |   |/
  `--''             ---`-' |  ,     .-./---`-' |  ,     .-./  `--'---'  |  ,   /         '---'
                            `--`---'            `--`---'                 ---`-'
*/




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

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

    vector<vector<int>> dp(2,vector<int>(N.size()+1,0));
    rep(n,1,N.size()+1){
        int numN=N.at(n-1)-'0';
        dp.at(0).at(n)=dp.at(0).at(n-1)+numN;
        if(n==1) dp.at(1).at(n)=max(0,numN-1);
        else dp.at(1).at(n)=max(dp.at(0).at(n-1)+max(0,numN-1),
            dp.at(1).at(n-1)+9);
    }

    cout<<max(dp.at(0).at(N.size()),dp.at(1).at(N.size()))<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define YN {puts("YES");}else{puts("NO");}
const ll MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (ll i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(ll n, ll k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}
ll llpow(ll n,ll i){ll cnt=n;  for(ll j=0;j<i-1;j++){n*=cnt;}return n;}

int main() {
  int n,k;
  cin>>n>>k;
  vi l(n);
  rep(i,n) cin>>l[i];
  sort(all(l));
  reverse(all(l));
  int ans=0;
  rep(i,k){
    ans+=l[i];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3572
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

const int UF_MAX_N = 1010100;

int uf_parant[UF_MAX_N];
int uf_rank[UF_MAX_N];
int uf_group_size[UF_MAX_N];

void init(int n) {
  for (int i = 0; i < n; i++) {
    uf_parant[i] = i;
    uf_rank[i] = 0;
    uf_group_size[i] = 1;
  }
}

int find(int x) {
  if (uf_parant[x] == x) {
    return x;
  } else {
    return uf_parant[x] = find(uf_parant[x]);
  }
}

int get_size(int x) {
  x = find(x);
  return uf_group_size[x];
}

void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y) return;

  if (uf_rank[x] < uf_rank[y]) {
    uf_parant[x] = y;
    uf_group_size[y] += uf_group_size[x];
  } else {
    uf_parant[y] = x;
    uf_group_size[x] += uf_group_size[y];
    if (uf_rank[x] == uf_rank[y]) uf_rank[x]++;
  }
}

bool same(int x, int y) { return find(x) == find(y); }

ll N, M;

int main() {
  //
  init(201010);
  cin >> N >> M;
  rep(i, 0, M) {
    ll a, b;
    cin >> a >> b;
    unite(a, b);
  }

  ll ans = 0;
  repe(i, 1, N) { chmax(ans, ll(get_size(i))); }

  cout << ans;
}


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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

constexpr int INF = 1e9;
constexpr ll INFLL = 1e18;
constexpr int MOD = 1e9 + 7;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

int main(){
    ios::sync_with_stdio(false); cin.tie(nullptr);
    //cout << fixed << setprecision(6);
    int n; cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];

    ll ans = 0;
    int high = 0;
    for (int t : a){
        if (t > high) high = t;
        ans += (high - t);
    }

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

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

using namespace std;

void convert(int n, vector<int> *v) {
  if(n == 0) return;
  convert(n / 4, v);
  v->push_back(n % 4);
}

int main() {
  while(1) {
    int n;
    cin >> n;
    if(n == -1) break;

    vector<int> v;
    convert(n, &v);
    if(n == 0) v.push_back(0);
    for(int i = 0; i < v.size(); i++) {
      cout << v[i];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define For(i,j,k) for(register int i=(j);i<=(k);++i)
#define Forr(i,j,k) for(register int i=(j);i>=(k);--i)
using namespace std;

template<typename T>
inline void read(T &x){
	T p=1,c=getchar();
	x=0;
	while(!isdigit(c)){
		if(c=='-') p=-1;
		c=getchar();
	}
	while(isdigit(c)){
		x=(x<<1)+(x<<3)+(c^48);
		c=getchar();
	}
	x*=p;
}

const int N=1e5+10;
int n,a[N],ans;

int main(){
	read(n);
	a[0]=a[n+1]=0;
	For(i,1,n){
		read(a[i]);
		ans+=abs(a[i]-a[i-1]);	
	}
	ans+=abs(a[n]);
	For(i,1,n){
		int sum=ans;
		sum=ans-abs(a[i]-a[i-1])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1]);
		printf("%d\n",sum);
	}
	return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define f(i,a,b) for(i=a;i<=b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define ll long long
#define mod (1000*1000*1000+7)
#define scan1(x) scanf("%lld",&x)
#define scan2(x,y) scanf("%lld %lld",&x,&y)
#define scan3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define print(x) printf("%lld\n",x)
#define ff first
#define ss second
using namespace std;


int main(){
    ll n,i,j,ans=0;
    string s1,s2;
    cin>>s1>>s2;
    n=s1.length();
    f(i,0,n-1)
    if(s1[i]!=s2[i])
    ans++;
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3924
#include<iostream>
#define ll long long
#define MOD 1000000007

using namespace std;
int main()
{
    int n;
    cin>>n;
    ll int *arr=new ll int[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    ll int *dp=new ll int[n+1]();
    dp[1]=0;
    dp[2]=dp[1]+abs(arr[1]-arr[0]);
    for(int i=3;i<=n;i++)
    {
        dp[i]=min(abs(arr[i-1]-arr[i-2])+dp[i-1],abs(arr[i-1]-arr[i-3])+dp[i-2]);
       
    }
    cout<<dp[n]<<endl;
}


Measured memory_bytes: 4764
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::{vec, cmp, num};


struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner {cin: cin}
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
                    .skip_while(|c| c.is_whitespace())
                    .take_while(|c| !c.is_whitespace())
                    .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

// create Vec<char> from String
#[allow(dead_code)]
fn to_chars(s: String) -> vec::Vec<char> {
    let mut cs = s.chars();
    let mut res = vec::Vec::new();
    while let Some(c) = cs.next() {
        res.push(c);
    }
    res
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let a: i32 = sc.read();
    let b: i32 = sc.read();
    let h: i32 = sc.read();
    println!("{}", (a + b) * h / 2);
}

Measured memory_bytes: 4352
//                             In The Name Of Allah
#include <bits/stdc++.h>
#define ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define ll long long
#define pb push_back
#define int long long
using namespace std;

const ll N = 1e6 + 100, OO = 1e10 + 10, M = 1e9 + 7, lg = 22;
typedef pair <int, int> pii;
int b[N];

int32_t main() {
	int n;
	cin >> n;
	for(int i = 0; i < n - 1; i++) 
		cin >> b[i];
	b[n - 1] = OO;
	int ans = b[0];
	for(int i = 1; i < n; i++) {
		if(b[i - 1] >= b[i])
			ans += b[i];
		else
			ans += b[i - 1];
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    int N,M,i,j,ki,on_count;
    int result=0;
    vector<vector<int>> S;
    vector<int> P;
    cin>>N>>M;
    S.resize(M,vector<int>(N));
    P.resize(M);
    for(i=0;i<M;i++){
        cin>>ki;
        for(j=0;j<ki;j++)cin>>S[i][j];
        S[i].resize(ki);
    }
    for(i=0;i<M;i++)cin>>P[i];


    for(int bit=0;bit<(1<<N);bit++){
        on_count=0;
        vector<int> lamp(N);
        vector<int> count(M);
        for(i=0;i<N;i++){
            if(bit&(1<<i)){
                lamp[i]=1;
            }
        }
        for(i=0;i<M;i++){
            for(j=0;j<S[i].size();j++)count[i]+=lamp[S[i][j]-1];
        }
        for(i=0;i<M;i++)if(count[i]%2==P[i])on_count+=1;
        if(on_count==M)result++;
    }
    cout<<result<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    std::deque<int> arr(10001,1);
    std::deque<int> prime;
    arr[0]=0;
    arr[1]=1;
    for (int i=2;i*i<10000;i++) {
        if (arr[i]==1) {
            for (int j=i*i;j<10000;j+=i) {
                arr[j]=0;
            }
        }
    }
    for (int k=2;k<=10000;k++) {
        if (arr[k]==1) {
            prime.emplace_back(k);
        }
    }
    int n;
    while (cin>>n) {
        if (n==0) {
            break;
        } else {
            auto itr=upper_bound(prime.begin(),prime.end(),n);
            int dis=distance(prime.begin(),itr);
            dis--;
            for (int l=dis;l>0;l--) {
               if (prime[l]-prime[l-1]==2) {
                    cout<<prime[l-1]<<" "<<prime[l]<<endl;
                    break;
                }
            }
        }
    }
}


Measured memory_bytes: 3128
// #include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;

#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0; i<n; i++)

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

    vector<int> cnt(n);
    int temp;

    for(int x=1; x<n/x; x++) for(int y=1; y<n/y; y++) for(int z=1; z<n/z; z++) {
        temp = x*x + y*y + z*z + x*y + y*z + z*x;
        if (temp<=n) cnt[temp-1]++;
    }

    rep(i, n) cout << cnt[i] << endl;

    return 0;
}

Measured memory_bytes: 3548
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define inf  1000000000
#define mod  1073741824
#pragma GCC optimization ("O3")
using namespace std;
const int N = 100*1000+5;
#define all(x) begin(x),end(x)
int main()
{
   
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    string n;
    cin >> n;
    int l = 0;
    long long int ans = 0;
    for (long long int i = n.size()-1; i >= 0 ; i--)
    {
        char c = n[i];
        int dig = (c - '0') + l;
        l = 0;
        if(dig > 10)
        {
            l += 1;
            dig =  10 - dig;
        }
        if(dig > 5 || (i != 0 && dig == 5 && (n[i-1] - '0') > 4))
        {
            ans += 10 - dig;
            l += 1;
        }
        else
        {
            ans += dig;
        }
    }
    if(l)
        ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1948
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod =1e+9+7;

vector<ll>prime_factorize(ll n){
    vector<ll>res;
    for(ll p = 2;p <= sqrt(n);p++){
        ll cnt=0;
      if (n%p != 0) continue;
      while(n % p == 0){
        n /= p;
        cnt++;
      }
       res.push_back(cnt);
      
    }
    if (n != 1) res.push_back(1);
    return res;
}

int main(){
    ll n; cin>>n;
    vector<ll>data=prime_factorize(n);

    ll ans=0;
    for(int j=0;;j++){
        bool jud=false;
    rep(i,data.size()){
        if(data[i]-(j+1)<0){
            continue;
        }
        else{
            data[i]-=j+1;
            jud=true;
            ans++;
        }
    }
    if(!jud){
        cout<<ans<<endl;
        return 0;
    }
    }

}









































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

int main() {
  int h, w;
  cin >> h >> w;
  int a[101][101] = {};
  int n;
  cin >> n;
  queue<pair<int,int>> b;
  for (int i = 0; i < n; i++) {
    int bb;
    cin >> bb;
    b.push({bb, i + 1});
  }

  for (int i = 0; i < h; i++) {
    if (i & 1) {
      for (int j = w - 1; j >= 0; j--) {
        a[i][j] = b.front().second;
        b.front().first--;
        if (b.front().first == 0) b.pop();
      }
    } else {
      for (int j = 0; j < w; j++) {
        a[i][j] = b.front().second;
        b.front().first--;
        if (b.front().first == 0) b.pop();
      }
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cout << a[i][j];
      if (j != w - 1) cout << " ";
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 384
st = gets.split.map(&:to_sym)
n = gets.split.map(&:to_i)
hash = {}
hash[st[0]] = n[0]
hash[st[1]] = n[1]
k = gets.chomp
hash[k.to_sym] -= 1
puts "#{hash[st[0]]} #{hash[st[1]]}" 

Measured memory_bytes: 3836
def memfact(a,m):
    temp = 1
    yield temp
    for i in range(1,a+1):
        temp = temp * i % m
        yield temp
def comb(n,r,m):
    if r == 0: return 1
    return (memf[n]*pow(memf[r],m-2,m)*pow(memf[n-r],m-2,m)) % m


n,*a = map(int, open(0).read().split())
m = 1000000007
checker = set()
for i in range(n+1):
    if a[i] in checker:
        left = a.index(a[i])
        right = n - i
        break
    else:
        checker.add(a[i])
memf = []
mfappend = memf.append
for x in memfact(n+1,m):
    mfappend(x)
lr = left + right
for i in range(1,n+2):
    ans = comb(n+1,i,m)
    if i <= lr + 1:
        ans = (ans-comb(lr,i-1,m)) % m
    print(ans)

Measured memory_bytes: 21684
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}



int main(){
   char a,b;cin>>a>>b;
   if(a<b)cout<<'<';
   if(a==b)cout<<'=';
   if(a>b)cout<<'>';
}



Measured memory_bytes: 256
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    c = Counter(input())
    for k, v in c.items():
        if v % 2 != 0:
            print(No)
            return
    print(Yes)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3948
import math

n = int(input())

l = math.log10(n)

cnt = 0

if l < 1:
    print(n)
elif l < 2:
    print(9)
elif l < 3:
    print(9 + n - 99)
elif l < 4:
    print(9 + 999 - 99)
elif l < 5:
    print(9 + 999 - 99 + n - 9999)
else:
    print(9 +999 - 99 + 99999 - 9999)


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

int main()
{
  int n, ans = 0;
  vector<vector<int>> A(3, vector<int>(3));
  for (int i = 0; i < 3; i++)
  {
    for (int j = 0; j < 3; j++)
    {
      cin >> A[i][j];
    }
  }
  cin >> n;
  int b;
  for (int i = 0; i < n; i++)
  {
    cin >> b;
    for (int t = 0; t < 3; t++)
    {
      for (int j = 0; j < 3; j++)
      {
        if (A[t][j] == b)
          A[t][j] = 0;
      }
    }
  }
  
  
  if (A[0][0] == 0 and A[0][1] == 0 and A[0][2] == 0){
    ans = 1;
  }
  
  if (A[1][0] == 0 and A[1][1] == 0 and A[1][2] == 0)
    {
    ans = 1;
  }
  if (A[2][0] == 0 and A[2][1] == 0 and A[2][2] == 0)
    {
    ans = 1;
  }
  if (A[0][0] == 0 and A[1][0] == 0 and A[2][0] == 0)
    {
    ans = 1;
  }
  if (A[0][1] == 0 and A[1][1] == 0 and A[2][1] == 0)
    {
    ans = 1;
  }
  if (A[0][2] == 0 and A[1][2] == 0 and A[2][2] == 0)
   {
    ans = 1;
  }
  if (A[0][0] == 0 and A[1][1] == 0 and A[2][2] == 0)
   {
    ans = 1;
  }
  if (A[0][2] == 0 and A[1][1] == 0 and A[2][0] == 0)
   {
    ans = 1;
  }
  if (ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
inData = input().split(' ')
N = int(inData[0])
M = int(inData[1])
ZERO = 0
seisuC = int(inData[2])
seisuB = input().split(' ')
ansCnt = 0
for i in range(0, N):
    inData2 = input().split(' ')
    calc = 0
    for j in range(0, len(inData2)):
        calc += (int(inData2[j]) * int(seisuB[j]))
    calc += seisuC
    if calc > ZERO:
        ansCnt += 1

print(ansCnt)

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

int main(){
    int a,b;
    cin>>a>>b;
    string sa = "",sb = "";
    string tempa = std::to_string(a),tempb = std::to_string(b);
    for (int i=0;i<b;++i){
        sa+=tempa;
    }
    for (int i=0;i<a;++i){
        sb+=tempb;
    }
    if (sa<sb){
        cout<<sa;
    }
    else{
        cout<<sb;
    }
}

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

#[fastout]
fn main() {
    input! {
        mut x: i32, n: usize,
        mut p: [i32; n],
    }
    p.sort();
    let mut i = 0;
    while i  < n {
        if p[i] >= x {
            break;
        }
        i += 1;
    }
    if i != n && p[i] == x{
        let mut j = 1;
        loop {
            if i < j || x - j as i32 != p[i-j] {
                x -= j as i32;
                break;
            }
            if i+j >= n || x + j as i32 != p[i+j] {
                x += j as i32;
                break;
            }
            j += 1;
        }
        
    }
    println!("{}", x);
}


Measured memory_bytes: 2180
#include <cstdio>
#include <iostream>

using namespace std;

int main(){
	int n, q;
	while(1){
		cin >> n >> q;
		if(n == 0 && q == 0) break;
		int m, y, a[101]={0};
		for(int i = 0; i < n; i++){
			cin >> m;
			for(int j = 0; j < m; j++){
				cin >> y;
				a[y]++;
			}
		}
		int max=0;
		for(int k = 1; k < 101; k++){
			if(a[k] > a[max]) max = k;
		}
		if(a[max] >= q) cout << max << endl;
		else cout << 0 << endl;
	}
	return 0;
}

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

using namespace std;

int main(int argc, char *argv[]) {
    int64_t N;
    cin >> N;
    vector<int64_t> arr(N);

    for (int i = 0; i < N; i++) cin >> arr[i];
    int64_t all_xor = arr[0];
    for (int j = 1; j < N; j++) all_xor ^= arr[j];

    vector<int64_t> ans;
    for (int k = 0; k < N; k++) {
        cout << (all_xor ^ arr[k]) << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 4792
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision


#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;
#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } else return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } else return false; }

int main() {
	int x,y,z;
	cin >> x >> y >> z;

	cout << z << " " << x << " " << y;
	
}


Measured memory_bytes: 256
#include<iostream>
#define f first
#define s second
#define DIM (1 << 18 + 5)
using namespace std;
int n, i, q, x, val, maxim1, maxim2, u, niv, sol;
int nr[2];
pair<int, int> p[DIM], v[20], w[2][DIM], aux[DIM];
void solve(int t, int st, int dr){
    int i, j, m, u1, u2;
    nr[t] = 1;
    w[t][1] = make_pair(0, 0);
    for(i = st; i <= dr; i++){
        m = 0;
        u1 = u2 = 1;
        while(u1 <= nr[t] && u2 <= nr[t]){
            if(w[t][u1].s < w[t][u2].s + v[i].s){
                aux[++m] = w[t][u1];
                u1++;
            }
            else{
                aux[++m] = make_pair(w[t][u2].f + v[i].f, w[t][u2].s + v[i].s);
                u2++;
            }
        }
        for(; u2 <= nr[t]; u2++){
            aux[++m] = make_pair(w[t][u2].f + v[i].f, w[t][u2].s + v[i].s);
        }
        nr[t] = m;
        for(j = 1; j <= m; j++){
            w[t][j] = aux[j];
        }
    }
}
int main(){
    cin>> n;
    for(i = 1; i <= n; i++){
        cin>> p[i].f >> p[i].s;
    }
    cin>> q;
    for(; q; q--){
        cin>> x >> val;
        nr[0] = nr[1] = 0;
        maxim1 = maxim2 = niv = u = sol = 0;
        while(x != 0){
            v[++niv] = p[x];
            x = x / 2;
        }
        if(niv <= 9){
            solve(0, 1, niv);
        }
        else{
            solve(0, 1, 9);
            solve(1, 10, niv);
        }
        for(i = nr[0]; i >= 1; i--){
            if(w[0][i].s <= val){
                maxim1 = max(maxim1, w[0][i].f);
                while(u <= nr[1] && w[0][i].s + w[1][u].s <= val){
                    maxim2 = max(maxim2, w[1][u].f);
                    u++;
                }
                sol = max(sol, w[0][i].f + maxim2);
            }
        }
        cout<< sol <<"\n";
    }
}


Measured memory_bytes: 5724
#include<cstdio>
int rem[101010],a[101010];
int main(){
    int ans = 0, n, x;
    scanf("%d",&n);
    for(int i = 1; i <= n; i ++){
        scanf("%d",&x);
        if(x == i)
            rem[i] = 1;
    }

    for(int i = 1; i <= n; i ++){
        if(!rem[i])
            continue;
        if(rem[i+1])
            i ++;
        ans ++;
    }
    printf("%d",ans);
    return 0;
}


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


void solve(std::string S){
    int sum =700;
    
    for(int i = 0;i<3;i++){
    if(S[i]=='o')
    {
        sum += 100;  
    }
    }
    cout << sum << endl;
}

// Generated by 1.1.7.1 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(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;
const int MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

signed main() {
	int N, K;
	cin >> N >> K;
	vector<int>p(N);
	vector<double>v(N, 0);
	vector<double>a(N + 1, 0);
	rep(i, N) {
		cin >> p[i];
		v[i] = (double)(p[i]) * (double)(p[i] + 1) / (double)2 / (double)p[i];
		a[i + 1] = a[i] + v[i];
	}
	double mx = -INF;
	for (int i = 0; i < N - K + 1; i++) {
		mx = max(mx, a[K + i] - a[i]);
	}
	printf("%.10f", mx);
}

Measured memory_bytes: 4992
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

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

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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!{
        s: chars,
    }

    println!(
        "{}",
        s.iter()
            .enumerate()
            .filter(|&(i, _)| i % 2 == 0)
            .fold(String::new(), |acc, (_, c)| acc + &c.to_string())
    );
}


Measured memory_bytes: 4352
import numpy as np
from operator import itemgetter
 
N = int(input())
 
list = []
for i in range(N):
    a,b=input().split()
    list.append([a, int(b),i+1])
sort1 = sorted(list, key=itemgetter(0))
if N == 1:
  	print(1)
else:
    ans = []
    kari = []
    end = 1
    k = 1
    for i in range(0,N-1):
        if end == 1:
            kari.append(sort1[i])
        else:
            k = 0
        if sort1[i][0] == sort1[i+1][0]:  
            kari.append(sort1[i+1])
            end = 0
            if i+1 > N-2:
            	kari.sort(key=itemgetter(1),reverse=True)
            	ans.extend(kari)

        else:
            kari.sort(key=itemgetter(1),reverse=True)
            ans.extend(kari)
            if i+1 > N-2:
            	ans.append(sort1[i+1])
            kari = []
            end = 1
    
    for i in range(0,len(ans)):
        print(ans[i][2])

Measured memory_bytes: 12500
import sys
from itertools import combinations, permutations, product, combinations_with_replacement, accumulate
from heapq import heapify, heappop, heappush, heappushpop
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from math import sqrt, log, floor, ceil, factorial, cos, sin, pi #, gcd
from fractions import gcd
from operator import mul
from functools import reduce
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
LINF = 2**63-1
NIL = -LINF
MOD = 10**9+7
MGN = 4
def AST(exp: bool, msg: str = ""): assert exp, msg
def TAST(exp: bool, msg = ""):
    if exp is False: print("TAssertionError:", msg)
    while exp is False:
        pass
def EPR(msg): print(msg, file=sys.stderr)
def II(): return int(input())
def IF(): return float(input())
def IS(): return input().replace('\n', '')
def ILCI(n: int): return [II() for _ in range(n)]
def ILCF(n: int): return [IF() for _ in range(n)]
def ILI(): return list(map(int, input().split()))
def ILLI(n: int): return [[int(j) for j in input().split()] for i in range(n)]
def ILF(): return list(map(float, input().split()))
def ILLF(n: int): return [[float(j) for j in input().split()] for i in range(n)]
def LTOS(lst: list, sep: str = ' '): return sep.join(map(str, lst))
def DEC(lst: list): return list(map(lambda x: x-1, lst))
def INC(lst: list): return list(map(lambda x: x+1, lst))


def main():
    N, K = ILI()

    ans = 0.0
    for i in range(1,N+1):  # サイコロの出た目
        scr = i  # 現在のスコア
        pb = 1.0  # 現在のスコアとなる確率
        win = True  # 勝ち続けているか
        while True:
            if K <= scr:  # 勝ち
                break
            elif 0 < scr < K:
                scr *= 2
                pb *= 0.5
            else:  # 負け
                TAST(True, "ここには来ない")
                scr = 0
                win = False
                break
        if win:
            ans += pb / N

    print("{:.12}".format(ans))


if __name__ == '__main__':
    main()


Measured memory_bytes: 5164
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e5;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

string s;

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

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

vector<int> a;

bool dfs(int m, int p = 0) {
	if (p == a.size()) return m == 0;
	if (dfs(m, p+1)) return true;
	if (m < a[p]) return false;
	return dfs(m-a[p], p+1);
}

int main() {
	int n;
	cin >> n;
	a.resize(n);
	for (auto& x:a) cin >> x;
	int q;
	cin >> q;
	while (q--) {
		int m;
		cin >> m;
		if (dfs(m)) cout << "yes" << endl;
		else cout << "no" << endl;
	}
}


Measured memory_bytes: 3088
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>
#include <iterator>
#include<random>



#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
using namespace std;
int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 500050;


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

	string S; cin >> S;
	REP(i, 3) {
		if (S[i] == S[i + 1]) {
			print("Bad");
			return 0;
		}
	}
	print("Good");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

int main()
{
  int n;
  while (scanf("%d", &n) != EOF)
  {
    lli a[n];
    for (int i = 0; i < n; i++)
      scanf("%lld", &a[i]);

    sort(a, a+n, greater<lli>());
    lli ans = a[0];
    if (n > 2)
    for (int i = 1, at = 1; i < n; at++)
      for (int j = 0; j < 2; j++, i++)
        if (i < n - 1)
          ans += a[at];
    printf("%lld\n", ans);
  }
  return 0;
}

Measured memory_bytes: 5320