akhauriyash/Code-Regression huggingface dataset:
# coding: utf-8

# https://atcoder.jp/contests/abc094/tasks/arc095_b
# 15:10-15:18


def main():
    N = int(input())
    A = list(map(int, input().split()))
    A = sorted(A)

    ai = A[-1]
    aj = A[0]
    border = ai / 2
    for j in range(N):
        if abs(border-A[j]) < abs(border-aj):
            aj = A[j]
    
    return ai, aj


for x in main():
    print(x, end=" ")


Measured memory_bytes: 14052
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         fozubaoyou    pass System Test!
*/


//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

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 SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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


int vector_finder(std::vector<int> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}


int main(){
    string s;
    cin >> s;
    string t;
    cin >> t;
    int x = s.length();

    bool check = 1;
    REP(i,x){
        if(s.at(i) != t.at(i)){
            check = 0;
            break;
        }
    }

    cout << ((check == 1) ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef tuple<int,int,int> T;
bool infect[20000];
int main() {
    int N,M;
    while(scanf("%d %d",&N,&M),N) {
        memset(infect,0,sizeof(infect));
        infect[0]=1;
        vector<T> v;
        for(int i=0;i<M;i++) {
            int t,s,d;
            scanf("%d %d %d",&t,&s,&d);s--;d--;
            v.push_back(make_tuple(t,s,d));
        }
        sort(v.begin(),v.end());
        for(int i=0;i<v.size();i++) {
            int s=get<1>(v[i]),d=get<2>(v[i]);
            if(infect[s]) infect[d]=1;
        }
        int ans=0;
        for(int i=0;i<N;i++) ans+=infect[i];
        printf("%d\n",ans);
    }
}

Measured memory_bytes: 3464
#include <iostream>
using namespace std;
int main(){

	long a,b;
	
	while(cin>>a>>b){
		long c = a+b;
		long d = 1;
		long e = 10;
		for(int j=0;j<10;j++){
			if(c == 0){
				cout<<1<<endl;
			}else if(c >= d && c < e){
				cout<<j+1<<endl;
			}
			d = d * 10;
			e = e * 10;
		}
		
	}	
	return 0;
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while(true) {
    c -= b;
    if (c <= 0) {
      cout << "Yes" << endl;
      return 0;
    }
    for(int i=0; i<1; i++) {
      a -= d;
      if (a <= 0) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 3552
#include<stdio.h>

int flag = 0;
int n,A[20];
void solve(int i, int m) {
    if( m == 0) {
        flag = 1;
        return;
    }
    
    if ( m < 0 || i == n )
        return ;
    
    solve(i+1, m);
    solve(i+1, m - A[i]);
}

int main()
{
    int q;
    int temp;
    scanf("%d",&n);
    for ( int i = 0; i < n; i++ ) scanf("%d",&A[i]);
    scanf("%d",&q);
    for ( int i = 0; i < q; i++ ) {
        flag = 0;
        scanf("%d",&temp);
        solve(0, temp);
        if(flag == 1) printf("yes\n");
        else printf("no\n");
    }
}



Measured memory_bytes: 2604
#include<iostream>
#include<cmath>


using namespace std;


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

    int s = a + b + c;
    int mx = max(a, max(b, c));

    s -= mx;
    s  = s + pow(2, k) * mx;

    cout << s;


    return 0;
}

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

  Graph G(n);
  int a, b;
  for(int i=0; i< m; i++){
    cin >> a >> b;
    G[a-1].push_back(b-1);
    G[b-1].push_back(a-1);
  }


  vector<int> michi(n, -1); //道しるべ

  queue<int> q;
  q.push(0);
  while(!q.empty()){
    int v = q.front();
    q.pop();

    for(int nv : G[v]){
      if(michi[nv]!=-1) continue;
      michi[nv] = v; 
      q.push(nv);
    }
  }

  for(int i=1; i<n; i++){
    if(michi[i]==-1){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  for(int i=1; i<n; i++) cout << michi[i]+1 << endl;
  return 0;
}

Measured memory_bytes: 10148
#include<stdio.h>
int main(void)
{
  char A[101],B[101],C[101];
  scanf("%s",A);
  scanf("%s",B);
  scanf("%s",C);
  
  int ai = 0;
  int bi = 0;
  int ci = 0;
  
  char x;	
  x=A[0];
  
  while(1){
    if(x=='a'){
      if(A[ai]=='\0'){
        printf("A");
        break;
      }
      else{
        x=A[ai];
		ai++;
      }
    }
		
    else if(x=='b'){
      if(B[bi]=='\0'){
        printf("B");
		break;
      }
      else{
        x=B[bi];
		bi++;
      }
    }
    
    else if(x=='c'){
      if(C[ci]=='\0'){
        printf("C");
		break;
      }
      else{
		x=C[ci];
		ci++;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll INF = 1145141919;
const ll MOD = 1000000007;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

map<ll, ll>s2m(set<ll>S){
    map<ll, ll>m;
    ll idx = 0;
    for(set<ll>::iterator it = S.begin(); it != S.end(); it++){
        m[*it] = idx;
        idx++;
    }
    return m;
}

ll dy[4] = {1, 0, -1, 0};
ll dx[4] = {0, 1, 0, -1};
ll path[111][111][4];
ll flg[111][111];

int main(){

	for(ll N; cin >> N, N; ){
        rep(i, 111)rep(j, 111)rep(k, 4)path[i][j][k] = 0;
        rep(i, 111)rep(j, 111)flg[i][j] = 0;
        ll L[55], T[55], R[55], B[55];
        set<ll>X, Y;
        X.insert(-1);
        X.insert(INF);
        Y.insert(-1);
        Y.insert(INF);
        rep(i, N){
            cin >> L[i] >> T[i] >> R[i] >> B[i];
            X.insert(L[i]);
            X.insert(R[i]);
            Y.insert(T[i]);
            Y.insert(B[i]);
        }
        map<ll, ll> XM = s2m(X), YM = s2m(Y);

        rep(i, N){
            ll l = XM[L[i]];
            ll t = YM[T[i]];
            ll r = XM[R[i]];
            ll b = YM[B[i]];
            for(ll x = l; x < r; x++){
                path[t][x][2] = 1;
                path[t - 1][x][0] = 1;
                path[b][x][2] = 1;
                path[b - 1][x][0] = 1;
            }
            for(ll y = b; y < t; y++){
                path[y][l][3] = 1;
                path[y][l - 1][1] = 1;
                path[y][r][3] = 1;
                path[y][r - 1][1] = 1;                
            }
        }
        ll cnt = 0;
        rep(y, 108)rep(x, 108){
            if(flg[y][x])continue;
            cnt++;
            flg[y][x] = cnt;
            queue<P>Q;
            Q.push(P(x, y));
            while(!Q.empty()){
                ll nx = Q.front().first;
                ll ny = Q.front().second;
                Q.pop();
                rep(i, 4){
                    ll tx = nx + dx[i];
                    ll ty = ny + dy[i];
                    if(tx < 0 || ty < 0 || tx >= 108 || ty >= 108)continue;
                    if(flg[ty][tx])continue;
                    if(path[ny][nx][i])continue;
                    flg[ty][tx] = cnt;
                    Q.push(P(tx, ty));
                }
            }
        }
        cout << cnt << endl;
    }

    return 0;
}


Measured memory_bytes: 3544
N = int(input())
A_i = list(map(int, input().split()))
count = 0

while all(s % 2 == 0 for s in A_i):
    count += 1
    for i in range(0, len(A_i)):
        A_i[i] = int(A_i[i] / 2)

print(count)

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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define inf 0x3f3f3f3f
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

/* 
 * * stuff you should look for
 * * int overflow, array bounds
 * * special cases (n=1?), set tle
 * */

int main(){
    fcin;

    string s;
    cin >> s;

    cout << string(s.size(), 'x');
    return 0;
}



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

using namespace std;

typedef long long ll;

#define MOD 1000000007

// x^n
ll mod_pow(ll x, ll n) {
  if (n == 0) return 1;
  ll res = mod_pow(x * x % MOD, n / 2);
  if (n & 1) res = res * x % MOD;
  return res;
}

// x^{-1}
ll mod_inv(ll x) { return mod_pow(x, MOD - 2); }

vector<ll> fact;
vector<ll> fact_inv;

void init_fact(int n) {
  fact.resize(n + 1);
  fact_inv.resize(n + 1);
  fact[0] = fact_inv[0] = 1;
  for (int i = 0; i < n; ++i) {
    fact[i + 1] = fact[i] * (i + 1) % MOD;
    fact_inv[i + 1] = fact_inv[i] * mod_inv(i + 1) % MOD;
  }
}

ll nCr(ll n, ll r) {
  if (n < r || n < 0 || r < 0) return 0;
  return fact[n] * fact_inv[r] % MOD * fact_inv[n - r] % MOD;
}

ll nPr(ll n, ll r) { return nCr(n, r) * fact[r] % MOD; }

int main() {
  int n, k;
  cin >> n >> k;
  vector<ll> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  init_fact(2 * n);
  ll ans = 0;
  for (int i = 0; i < n; ++i) {
    ll mx = nCr(i, k - 1) % MOD;
    mx = (mx * a[i]) % MOD;
    ll mn = nCr(n - 1 - i, k - 1) % MOD;
    mn = (mn * a[i]) % MOD;
    ll res = (mx - mn + MOD) % MOD;
    ans = (ans + res) % MOD;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/

#define MAX_V 10010

vector<pair<ll, ll>> G[MAX_V];

// ダイクストラ法
vector<ll> dijkstra(ll start) {
	vector<ll> dist(MAX_V, infll);
	dist[start] = 0; // dist[i] := start->iまでの最短距離
	priority_queue < pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> que;
	que.push({ 0, start });
	while (!que.empty()) {
		ll cost, u; // 今までにかかった時間　現在の頂点
		cost = que.top().first, u = que.top().second;
		que.pop();
		if (dist[u] < cost) continue;
		for (auto tmp : G[u]) {
			ll v = tmp.first, time = tmp.second; // 隣接する頂点、その頂点まで行く時間
			if (dist[v] > dist[u] + time) {
				dist[v] = dist[u] + time;
				que.push({ dist[v], v });
			}
		}
	}
	return dist;
}

int n;
ll ans[MAX_V];
ll cnt = 0;
ll c[MAX_V];
bool used[MAX_V];

void dfs(int s) {
	if (used[s] == true) return;
	ans[s] = c[cnt++];
	used[s] = true;

	// 次にノード数の多い辺を先にやる
	sort(allof(G[s]), [&](pair<ll, ll>& a, pair<ll, ll>& b) {
		return (int)G[a.first].size() > (int)G[b.first].size();
	});
	rep(i, (int)G[s].size()) {
		dfs(G[s][i].first);
	}
}

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

	cin >> n;

	vector<ll> a(n - 1), b(n - 1), tmpC(n);
	rep(i, n - 1) {
		cin >> a[i] >> b[i];
		G[a[i] - 1].push_back({ b[i] - 1, 0 });
		G[b[i] - 1].push_back({ a[i] - 1, 0 });
	}
	rep(i, n) cin >> tmpC[i];
	rep(i, n) used[i] = false;

	// 方針としては、辺が多い頂点に大きい値を与えたい
	// nは1e4なので比較的小さい もしかしたらO(n^2)もいける


	sort(allof(tmpC), greater<ll>());
	rep(i, n) {
		c[i] = tmpC[i];
	}
	/*
	vector<pair<ll, ll>> num(n);
	rep(i, n) num[i].second = i;

	// 隣の辺との差をできるだけ小さくした方がいいよね
	rep(i, n) {
		num[i].first = (int)G[i].size();
	}

	sort(allof(num), greater<pair<ll, ll>>());
	*/
	int maxIndex = 0;
	int maxNum = 0;
	rep(i, n) {
		if (maxNum < (int)G[i].size()) {
			maxNum = (int)G[i].size();
			maxIndex = i;
		}
	}

	dfs(maxIndex);

	ll res = 0;

	rep(i, n - 1) {
		// 辺を全通りみる
		ll mi;
		mi = min(ans[a[i] - 1], ans[b[i] - 1]);
		res += mi;
	}

	cout << res << endl;
	rep(i, n) cout << ans[i] << " ";
	cout << endl;


	return 0;
}


Measured memory_bytes: 1792
import java.util.*;
import java.io.*;
public class Main{
    static PrintWriter out;
    static Scanner sc;
    public static void main(String[] args){
        sc=new Scanner(System.in);
        out=new PrintWriter(System.out);

        int t=1;
      //  t=sc.nextInt();
        while(t-->0){
            forEachTestcase();
        }

        out.close();
    }

    static void forEachTestcase(){
        int n=sc.nextInt();
        int m=sc.nextInt();
        l=new ArrayList[n];
        for(int i=0;i<n;i++){
            l[i]=new ArrayList<>();
        }
        for (int i = 0; i <m ; i++) {
            int u=sc.nextInt()-1;
            int v=sc.nextInt()-1;
            l[u].add(v);
            l[v].add(u);
        }
        int vis[]=new int[n];
        int ans=0;
        for(int i=0;i<n;i++){
            if(vis[i]==0){
                ans++;
                dfs(i,vis);
            }
        }
        out.println(ans-1);
    }
    static ArrayList<Integer> l[];
    static void dfs(int u,int vis[]){
        vis[u]=1;
        for(int v:l[u]){
            if(vis[v]==0){
                dfs(v,vis);
            }
        }
    }

    static class modOpeation{
        static long mod;
        modOpeation(long mod){
            this.mod=mod;
        }
        static long mul(long a,long b){
            a%=mod;
            b%=mod;
            return (a*b)%mod;
        }
        static long add(long a,long b){
            a%=mod;
            b%=mod;
            return (a+b)%mod;
        }
        static long sub(long a,long b){
            a%=mod;
            b%=mod;
            return ((a-b)%mod+mod)%mod;
        }
        static long modPow(long a,long b){
            long ans=1;
            while(b>0){
                if(b%2==1)ans=mul(ans,a);
                a=mul(a,a);
                b>>=1;
            }
            return ans;
        }
        static long modInv(long a){
            return modPow(a,mod-2);
        }
        static long ifact[],fact[];
        static long nCr(int n,int r){
            if(r>n)return 0;
            return mul(fact[n],mul(ifact[r],ifact[n-r]));
        }
        static void initFactorial(int max){
            fact=new long[max];
            ifact=new long[max];
            fact[0]=ifact[0]=1;
            for (int i = 1; i <max ; i++) {
                fact[i]=mul(fact[i-1],i);
                ifact[i]=mul(ifact[i-1],modInv(i));
            }
        }
    }

}

Measured memory_bytes: 75608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[101][100001];
int main()
{
	ios_base::sync_with_stdio(0); 
    cin.tie(0);   
	ll n,m,k,ans=0,fl=0;
	string s;
	vector <pair<ll,ll> > v;
	cin>>n>>k;
	v.push_back(make_pair(0,0));
	for(int i=0;i<n;i++)
	{
		ll u,d;
		cin>>u>>d;
		v.push_back(make_pair(u,d));
	}
	for(int i=0;i<101;i++)
		for(int j=0;j<100001;j++)
			a[i][j]=-1;
	sort(v.begin(),v.end());
	a[0][0]=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=k;j++)
		{
			ll w=v[i].first,val=v[i].second;
			a[i][j]=a[i-1][j];
			// cout<<i<<" "<<j<<" "<<j-w<<endl;
			if(j-w>=0 && a[i-1][j-w]!=-1)
			{
				a[i][j]=max(a[i][j],a[i-1][j-w]+val);
				// cout<<i<<" "<<j<<" "<<a[i-1][j-w]<<" "<<a[i][j]<<endl;
			}
		}
	}
	ll ma=0;
	for(int i=0;i<=k;i++)
	{
		ma=max(ma,a[n][i]);
	}
	cout<<ma<<endl;
	return 0;
}

Measured memory_bytes: 82500
#include<bits/stdc++.h>
using namespace std;
struct  Point
{
    int x,y;
    Point(int x,int y):x(x),y(y) {}
};
int h,w,grid[1000][1000];
int main()
{
    cin>>h>>w;
    stack<Point> sta;
    int ans=0;
    for(int i=1; i<=h; i++)
    {
        for(int j=1; j<=w; j++)
            cin>>grid[i][j];
    }
    for(int i=1; i<=h; i++)
    {
        if(i%2!=0)
        {
            for(int j=1; j<=w; j++)
            {
                if(grid[i][j]%2!=0&&j<w)
                {
                    grid[i][j+1]-=1;
                    sta.push(Point(i,j));
                    sta.push(Point(i,j+1));
                }
                else if(grid[i][j]%2!=0&&j==w)
                {
                    grid[i+1][j]-=1;
                    sta.push(Point(i,j));
                    sta.push(Point(i+1,j));
                }
            }
        }
        else
        {
            for(int j=w; j>0; j--)
            {
                if(grid[i][j]%2!=0&&j>1)
                {
                    grid[i][j-1]-=1;
                    sta.push(Point(i,j));
                    sta.push(Point(i,j-1));
                }
                else if(grid[i][j]%2!=0&&j==1)
                {
                    grid[i+1][j]-=1;
                    sta.push(Point(i,j));
                    sta.push(Point(i+1,j));
                }
            }
        }
    }
    while(!sta.empty()&&grid[sta.top().x][sta.top().y]<0)
    {
        sta.pop();
    }
    if(sta.size()%2!=0)
        sta.pop();
    cout<<sta.size()/2<<endl;
    while(!sta.empty())
    {
        cout<<sta.top().x<<" "<<sta.top().y<<" ";
        sta.pop();
        cout<<sta.top().x<<" "<<sta.top().y<<endl;
        sta.pop();
    }
    return 0;
}


Measured memory_bytes: 6068
#include<bits/stdc++.h>
using namespace std;
long long n;
long long a[55];
long long res=0;
bool cmp(long long a,long long b) {
	return a>b;
}
int main() {
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	sort(a+1,a+n+1,cmp);
	long long ma=a[1];
	while(ma>n-1) {
		long long tmp=ma/n;
		a[1]=ma%n;
		res+=tmp;
		for(int i=2;i<=n;i++)
				a[i]+=tmp;
		sort(a+1,a+n+1,cmp);
		ma=a[1];
	}
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vlll = vector<vll>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
//AtCoder以外ではコメントアウトを忘れずに！
//#include <atcoder/all>
//using namespace atcoder;
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod, LIS, digitDP, treeDP, Rerooting//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA, FordFulkerson//
ll i, j, k, l; ll N, M, K, H, W, X, Y, Z, R, Q, T;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vl flag, D; vll path; vs S;
//***********//
int main() {
	string S;
	cin >> S;
	if (S[S.length() - 1] == 's') S += "es";
	else S += 's';
	cout << S;
}


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

using namespace std;

int main()
{
	int n;
	cin >> n;
	
	int sum = 0;
	vector<int> p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
		sum += p[i];
	}
	
	int max = *max_element(p.begin(), p.end());
	sum -= max / 2;
	
	cout << sum << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  long long int n;
  cin>>n;
  vector<long long int> a(n);
  for(long long int i=0; i<n; i++){
    cin>>a.at(i);
  }
  vector<long long int> pre(n,0);
  vector<long long int> hoge;
  long long int ans=0;
  for(long long int i=n-1; i>=0; i--){
    long long int now=0;
    long long int step=1;
    long long int start=n-n%(i+1)-1;
    for(long long int j=start; j>i; j-=step){
      if((j+1)%(i+1)==0){
        step=i+1;
        now+=pre.at(j);
      }
    }
    if(now%2!=a.at(i)){
      ans++;
      hoge.push_back(i+1);
      pre.at(i)=1;
    }
  }
  cout<<ans<<endl;
  for(long long int i=0; i<hoge.size(); i++){
    cout<<hoge.at(i)<<endl;
  }
}

Measured memory_bytes: 4980
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scanf("%d %d", &a, &b)
	s := ""
	if a == b {
		for i := 0; i < a; i++ {
			s += fmt.Sprintf("%d", a)
		}
	} else if a > b {
		for i := 0; i < a; i++ {
			s += fmt.Sprintf("%d", b)
		}
	} else {
		for i := 0; i < b; i++ {
			s += fmt.Sprintf("%d", a)
		}
	}
	fmt.Println(s)
}


Measured memory_bytes: 512
#[allow(unused_macros)]
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 ( 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 ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
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! {
        w: i64,
        a: i64,
        b: i64
    }

    let ret = if a+w < b {
        b - (a+w)
    } else if b+w < a {
        a - (b+w)
    } else {
        0
    };
    println!("{}", ret);
}


Measured memory_bytes: 4352
n = int(input())
a = list(map(int, input().split()))
r = []
l = []
for i in range(n):
  if i % 2 == 0:
    r.append(a[i])
  else:
    l.append(a[i])

if n % 2 == 0:
  ans = l[::-1]+r
else:
  ans = r[::-1]+l
print(" ".join(map(str, ans)))


Measured memory_bytes: 37088
import Data.List (elemIndex)
import Data.Maybe (fromJust)

main :: IO ()
main = do
  n <- readLn :: IO Int
  let d = map (\x -> f x 0) [1..n]
  print $ [1..n] !! fromJust (elemIndex (maximum d) d)

f :: Int -> Int -> Int
f n i
  |odd n = i
  |odd $ n`div`2 = i + 1
  |otherwise = f (n `div` 2) (i+1)



Measured memory_bytes: 508
import numpy as np
n,a=map(int,input().split())
x=list(map(int,input().split()))
s=sum(x)
dp=np.zeros((n,s+1),dtype=np.int64)
for i in range(n):
    for j in range(i)[::-1]:
        dp[j+1][x[i]:]+=dp[j][:-x[i]]
    dp[0][x[i]]+=1
t=0
for k in range(n):
    if (k+1)*a<=s:
        t+=dp[k][(k+1)*a]
print(t)

Measured memory_bytes: 27752
import sys

n = input()
x = list(map(int, input().split()))
#x = [i for i in range(2, 10**5)]

MAXA = 10**6

used = [False for i in range(MAXA + 5)]
result = 0
counts = {}
for a in x:
	if a in counts:
		counts[a] += 1
	else: 
		counts[a] = 1

for x in range(MAXA + 1):
	if not used[x]:
		if x in counts:
			count = counts[x]		
			if count == 1:
				result += 1

			y = 2*x
			while y <= MAXA:
				used[y] = True
				y += x

print(result)


Measured memory_bytes: 167540
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

void solve(string& s){
    int n=s.size();
    stack<char> st;
    st.push('a');
    rep(i,n){
        if(s[i]=='(')st.push('(');
        if(s[i]=='[')st.push('[');
        if(s[i]==')'){
            if(st.top()=='(')st.pop();
            else{
                cout<<"no"<<endl;
                return ;
            }
        }
        if(s[i]==']'){
            if(st.top()=='[')st.pop();
            else{
                cout<<"no"<<endl;
                return ;
            }
        }
    }
    if(st.size()==1)cout<<"yes"<<endl;
    else cout<<"no"<<endl;
}
int main(){
    string s;
    while(getline(cin,s),s!=".")solve(s);
    return 0;
}


Measured memory_bytes: 3144
fn solve() {
    let n: usize = read();
    let q: usize = read();
    let s: Vec<char> = read::<String>().chars().collect();
    let mut acc = vec![0, 0];
    let mut ac_count = 0;
    for i in 1..s.len() {
        if s[i - 1] == 'A' && s[i] == 'C' {
            ac_count += 1;
        }
        acc.push(ac_count);
    }
    for i in 0..q {
        let (l, r): (usize, usize) = (read::<usize>(), read::<usize>());
        println!("{}", acc[r] - acc[l]);
    }
}

fn main() {
    let stack_size = 104_857_600;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min, Reverse};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


Measured memory_bytes: 2460
import itertools

N, M, R = map(int, input().split())
r = [int(s) - 1 for s in input().split()]
a, b, c = [0] * M, [0] * M, [0] * M
for i in range(M):
    a[i], b[i], c[i] = map(int, input().split())
    a[i] -= 1
    b[i] -= 1

wf = [[float('inf')] * N for _ in range(N)]
for i in range(M):
    wf[a[i]][b[i]] = c[i]
    wf[b[i]][a[i]] = c[i]

for k, i, j in itertools.product(range(N), repeat=3):
    wf[i][j] = min(wf[i][j], wf[i][k] + wf[k][j])

x = float('inf')
for route in itertools.permutations(r):
    y = sum(wf[route[i]][route[i + 1]] for i in range(R - 1))
    x = min(x, y)

print(x)

Measured memory_bytes: 67928
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    
    
    multiset<int> st;
    vector<int> ans;
    rep(k,n){
        if(st.count(-a[k])==0){
            st.insert(a[k]);
        }else{
            st.erase(st.find(-a[k]));
        }

        if(st.count(a[n-k-1])==0){
            st.insert(-a[n-k-1]);
        }else{
            st.erase(st.find(a[n-k-1]));
        }
        
        if(st.size()==0)ans.pb(k);
    }
    rep(i,ans.size()){
        if(i)cout<<" ";
        cout<<ans[i]+1;
    }
    cout<<endl;
}



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

using namespace std;

int main()
{
    string s;
    cin >> s;
    bool TF = false;
    if (s=="hi" ||
    s=="hihi" ||
    s=="hihihi" ||
    s=="hihihihi" ||
    s=="hihihihihi")
    {
        TF = true;
    }
    if(TF==true)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
        int a,b;
        cin>>a>>b;
        int x;
        for(int i=a;i<=b;i++){
                if((i/10000)%10==i%10&&(i/1000)%10==(i/10)%10){
                        x++;
                }
        }
        cout<<x;
}

Measured memory_bytes: 256
//In The Name Of God
#include <bits/stdc++.h>
#define int long long
#define F first
#define S second
#define mp make_pair
#define L(x) (2*(x))
#define R(x) ((2*(x))+1)
#define pii pair<int, int>
#define pb push_back
using namespace std;
const int N = 2e6 + 5, Mod = 1e9 + 7, P = 727, Lg = 22, TOF = 1900;

int Dp[N], H[N];
int32_t main(){
      ios_base::sync_with_stdio(0); cin.tie(0);
      int n; cin >> n;
      for(int i = 1; i <= n; i++)
            cin >> H[i];
      for(int i = 2; i <= n; i++){
            Dp[i] = Dp[i - 1] + abs(H[i] - H[i - 1]);
            if(i > 2)
                  Dp[i] = min(Dp[i], Dp[i - 2] + abs(H[i] - H[i - 2]));
      }
      cout << Dp[n];
      return 0;
}



Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int  main()
{
	string s; cin >> s;
	map <char, int> mp;
	rep(i, s.size())
		mp[s[i]]++;
	if (mp.size() == 2)
	{
		if (mp[s[0]] == 2 && mp[s[1]] == 2 && mp[s[2]] == 2)
		{
			cout << "Yes\n"; return 0;
		}
	}
	cout << "No\n";
	return 0;
}


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

int main() {
	int n, sum = 0, suml = 0, ans = 100;
	cin >> n;
	vector<int> w(n);
	for (int i = 0; i < n; ++i) {
		cin >> w[i];
		sum += w[i];
	}
	for (int i = 0; i < n; ++i) {
		suml += w[i];
		ans = min(abs(sum - 2*suml), ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n,r,i;
	r=2;
	scanf("%d",&n);
	for(i=0;r<n;i++){
		r=2*r;
	}
	if(r>n){
		r=r/2;
	}
	printf("%d\n",r);
	return 0;
}


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

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 200007;
const int MOD = 1e9 + 7;

struct iT
{
	int x, v;
}it[MAXN];

struct sT
{
	int l, r;
}sg[MAXN];

int n;
int pmax[MAXN], pmin[MAXN];
LL dp[MAXN], ps[MAXN];


void init ();
void input ();
void work ();



int main()
{
	init();
	input();
	work();
}



void init ()
{
	// Init Everything Here

	ios::sync_with_stdio ( false );
}

void input ()
{
	// input method

	scanf ( "%d", &n );
	lpi ( i, 1, n ) scanf ( "%d%d", &it[i].x, &it[i].v );
}

void work ()
{
	// main work

	if ( n == 1 ){
		printf ( "1\n" );
		return;
	}

	sort ( it+1, it+1+n, []( iT &x, iT &y ) { return ( x.v < y.v ); } );

	pmax[0] = 0;
	lpi ( i, 1, n ) pmax[i] = qmax ( pmax[i-1], it[i].x );
	pmin[n+1] = INF;
	lpd ( i, n, 0 ) pmin[i] = qmin ( pmin[i+1], it[i].x );

	int l, r, mid;
	lpi ( i, 1, n ){
		l = 1, r = i;
		while ( l < r ){
			mid = ( l + r ) >> 1;
			if ( pmax[mid] >= it[i].x ) r = mid;
			else l = mid + 1;
		}
		sg[i].l = l + 1;
		l = i, r = n;
		while ( l < r ){
			mid = ( l + r + 1 ) >> 1;
			if ( pmin[mid] <= it[i].x ) l = mid;
			else r = mid - 1;
		}
		sg[i].r = l + 1;
	}

	sort ( sg+1, sg+1+n, []( sT &x, sT &y ) { return ( ( x.r ^ y.r ) ? ( x.r < y.r ) : ( x.l < y.l ) ); } );

	int pr = 0;
	dp[1] = 1;
	lpi ( i, 1, n+1 ) ps[i] = 1;
	lpi ( i, 1, n ){
		l = sg[i].l, r = sg[i].r;
		for ( ; pr < r; ++pr ) ps[pr+1] = ( ps[pr] + dp[pr+1] ) % MOD;
		( dp[r] += ps[r] - ps[l-2] + MOD ) %= MOD;
		ps[r] = ( ps[r-1] + dp[r] ) % MOD;
	}

	printf ( "%lld\n", dp[n+1] );
}

Measured memory_bytes: 8064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1e9;
const ll mod = 1e9 + 7;

int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}

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

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

int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};


/////////////////////////////////////////////////////////////////////////////////////

int main() {
    long long n;
    cin >> n;
    string ans = "";
    long long d, amari;
    while(n){
        --n;
        ans += (char)('a'+ (n % 26));
        n /= 26;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
const int mod = 1e9+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);

int N;

signed main()
{
    cin >> N;
    vi A(N), B(N), C(N);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    rep(i, N) cin >> C[i];

    sort(all(A));
    sort(all(C));

    int ans = 0;

    rep(i,N)
    {
        auto low = lower_bound(all(A), B[i]);
        int ac = low - A.begin();
        auto high = upper_bound(all(C), B[i]);
        int cc = C.end() - high;
        ans += ac * cc;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5632
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int w,h;
char fie[23][23];
int check[23][23];
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

int solve(int x,int y){
  int ret=1;
  check[x][y]=1;
  for(int i=0;i<4;i++){
    if(x+dx[i] < 0 || x+dx[i] >= w || y+dy[i] <0 || y+dy[i] >=h) continue;
    if(fie[x+dx[i]][y+dy[i]]=='.' && check[x+dx[i]][y+dy[i]]==0){
      ret+=solve(x+dx[i],y+dy[i]);
    }
  }
  return ret;
}

main(){
  while(1){
    int x,y;
    cin >> w>>h;
    if(!w || !h) break;
    memset(check,0,sizeof(check));
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin >> fie[j][i];
	if(fie[j][i]=='@'){ x=j;y=i;}
      }
    }
    cout << solve(x,y) << endl;
  }

}

Measured memory_bytes: 0
/* 	* In the name of GOD 
	* Thanks God */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define int long long
const int M = 1000 * 1000 * 1000 + 7;

int32_t main(){
	int n, k;
	cin >> n >> k;
	int a[n];
	for (int i = 0; i < n; i++){
		cin >> a[i];
	}
	int su1 = 0, su2 = 0;
	for (int i = 0; i < n; i++){
		for (int j = i + 1; j < n; j++){
			su1 += (a[i] > a[j]);
		}
	}
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			su2 += (a[i] > a[j]);
		}
	}
	su1 %= M;
	su2 %= M;
	int x = (su1 * k) % M;
	int y = (k) * (k - 1);
	y /= 2;
	y %= M;
	y *= su2;
	y %= M;
	cout << (x + y) % M; 
}


Measured memory_bytes: 3612
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=405;
const int mod=1e9+7;
int a[N],b[N];
int n,c;
ll ans=0;
ll ksm(ll x,ll y){
    ll res=1;
    while(y){
        if(y&1){
            res=(res*x)%mod;
        }
        x=(x*x)%mod;
        y>>=1;
    }
    return res;
}
ll sum[N][N];
ll hjb[N][N];
int main()
{
        scanf("%d%d",&n,&c);
        for(int i=1;i<=n;i++){
            scanf("%d",&a[i]);
        }
        for(int i=1;i<=n;i++){
            scanf("%d",&b[i]);
        }
        for(int j=0;j<=c;j++)
            for(int k=a[1];k<=b[1];k++)
                sum[1][j]=(sum[1][j]+ksm(k,j))%mod;
        /*for(int i=2;i<=n;i++){
            for(int j=0;j<=c;j++){
                for(int k=a[i];k<=b[i];k++){
                    for(int l=0;l<=j;l++){
                        sum[i][j]=(sum[i][j]+ksm(k,l)*sum[i-1][j-l]%mod)%mod;
                    }
                }
            }
        }*/
        for(int i=2;i<=n;i++){
            for(int l=0;l<=c;l++){
                for(int k=a[i];k<=b[i];k++){
                    hjb[i][l]=(hjb[i][l]+ksm(k,l))%mod;
                }
                for(int j=l;j<=c;j++){
                    sum[i][j]=(sum[i][j]+hjb[i][l]*sum[i-1][j-l]%mod)%mod;
                }
            }
        }
        ans=0;
        ans=sum[n][c];
        printf("%lld\n",ans);
}


Measured memory_bytes: 2688
N = int( input() )

ac = 0
wa = 0
tle = 0
re = 0

for i in range(N):
  x = input()
  if x == "AC" :
    ac += 1
    
  elif x == "WA" :
    wa += 1
    
  elif x == "TLE" :
    tle += 1
    
  elif x == "RE" :
    re += 1

print("AC x " + str(ac) )
print("WA x " + str(wa) )
print("TLE x " + str(tle) )
print("RE x " + str(re) )

Measured memory_bytes: 9108
N = int(input())
edges = [list(map(lambda x: int(x)-1, input().split())) for _ in range(N-1)]
connected = [list() for _ in range(N)]
for e in edges:
  connected[e[0]].append(e[1])
  connected[e[1]].append(e[0])
for c in connected:
  c.sort()

ans = 0
current = 0
for i in range(N):
  # calculate any subgraph using upto i
  # i-1
  # i-1, i-2
  # i-1, i-2, ..., 0
  current += 1 + i # 1 for single vertex case, i for adding vertices to each i-1 case.
  for j in connected[i]:
    if j > i:
      break
    current -= j + 1  # subtract 1 for each edges
  #print(i, current)
  ans += current
  
print(ans)
  




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

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

    if(x >= 30){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); 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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n;
  cin >> n;
  set <ll> res;
  res.insert(n);
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) {
      ll tmp = n;
      while (!(tmp%i)) tmp /= i;
      if (tmp%i==1) res.insert(i);
      if (i != n/i) {
        ll tmp = n, div = n/i;
        while (!(tmp%div)) tmp /= div;
        if (tmp%div==1) res.insert(div);
      }
    }
  }
  for (ll i = 1; i*i <= n-1; i++) {
    if ((n-1)%i == 0) {
      res.insert(i);
      if (i != (n-1)/i) res.insert((n-1)/i);
    }
  }
  cout << res.size()-1 << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    vector<int> a(n);
    map<int,int> mp;
    int mx=0;
    rep(i,n){
        cin>>a[i];
        mp[a[i]]++;
        chmax(mx,a[i]);
    }
    if(n==2){
        cout << (mp[1]==2 ? "Possible" : "Impossible") << endl;
        return 0;
    }
    bool first = true;
    bool second = true,single=false;
    int cnt;
    int prev;
    for(auto x:mp){
        if(first){
            first=false;
            cnt = x.first;
            if(mx%2==0&&x.second==1){
                single=true;

            }
            else if(mx%2==1&&x.second==2){
                cnt--;
            }
            else{
                cout << "Impossible" << endl;
                return 0;
            }
            prev = x.first;
            continue;
        }

        if(x.second<2){
            cout << "Impossible" << endl;
            return 0;
        }
        prev = x.first;
        cnt--;
    }
    cout << (cnt==0 ? "Possible" : "Impossible") << endl;
    return 0;
}


Measured memory_bytes: 256
from itertools import permutations
n=int(input())
num=[str(i+1) for i in range(n)]
nums=sorted([int("".join(i)) for i in permutations(num,n)])
P=int("".join(map(str,input().split())))
Q=int("".join(map(str,input().split())))
a,b=0,0
for j,i in enumerate(nums):
    if i==P:a=j
    if i==Q:b=j
print(abs(a-b))

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

int main(){
    int n, a, b;
    cin >> n >> a >> b;
    int c = n*a;
    if(c > b) cout << b << endl;
    else cout << c << endl;
    return 0;
}

Measured memory_bytes: 3536
import sys
sys.setrecursionlimit(10 ** 7)

N = int(input())
flist = [list(map(int, input().split())) for _ in range(N)]
plist = [list(map(int, input().split())) for _ in range(N)]
alist = [0] * 10
def dfs(i, v, ans):
    if v == 10:
        tmp = 0
        if alist.count(1) == 0:
            return ans
        for j in range(N):
            cnt = 0
            for k in range(10):
                if alist[k] == 1 and flist[j][k] == 1:
                   cnt += 1
            tmp += plist[j][cnt]

        ans = max(ans, tmp)
        return ans

    alist[i] = 1
    ans = dfs(i + 1, v + 1, ans)
    alist[i] = 0
    ans = dfs(i + 1, v + 1, ans)
    return ans

print(dfs(0, 0, -10 ** 9 - 1))

Measured memory_bytes: 3064