akhauriyash/Code-Regression huggingface dataset:
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pll>
#define vpii vector<pii>
#define pb push_back
#define eb emplace_back
#define mt make_tuple
#define MP make_pair
#define fs first
#define sc second
#define F first
#define S second
#define nl "\n"
#define asche cerr<<"Ekhane asche\n";
#define pf printf
#define sf scanf
#define mem(a,x) memset(a,x,sizeof(a))
#define SZ(v) (int)v.size()
#define all(v) v.begin(),v.end()
#define one(x) __builtin_popcount(x)
#define fout(x) fixed<<setprecision(x)
#define BeatMeScanf ios_base::sync_with_stdio(false)
//int dx[]={1,0,-1,0,1,-1,-1,1};
//int dy[]={0,1,0,-1,1,1,-1,-1};
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); deb(_it, args); }
void deb(istream_iterator<string> it) {}
template<typename T, typename... Args>
void deb(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    deb(++it, args...);
}
//template <typename T> using o_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
namespace IO
{
    #define in() ( { int a ; scanf("%d",&a); a; } )
    #define LL() ( { ll a ; scanf("%lld",&a); a; } )
    #define ULL() ( { ull a ; scanf("%llu",&a); a; } )
    #define DD() ({ double a; scanf("%lf", &a); a;})
    #define CC() ( { char a ; scanf("%c",&a); a; } )
    #define pf1(a) printf("%d\n",a)
    #define pf1ll(a) printf("%lld\n",a)
}
using namespace IO;

const int mod=1e9+7;
const int N=3e5+9;
const double eps=1e-9;
const double PI=acos(-1.0);
ll qpow(ll n,ll k) {ll ans=1;assert(k>=0);n%=mod;while(k>0){if(k&1) ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return ans%mod;}

vll basis;
void add(ll x)
{
    for(auto &it:basis) if((x^it)<x) x^=it;
    for(auto &it:basis) if((it^x)<it) it^=x;
    if(x)  basis.pb(x);
}
ll a[N];
int cnt[66];
int32_t main()
{
    ///BeatMeScanf;
    int n=in();
    ll tot=0;
    for(int i=1;i<=n;i++){
        ll k=LL();
        for(int i=0;i<60;i++) if((k>>i)&1) cnt[i]^=1;
        a[i]=k;
    }
    for(int i=1;i<=n;i++){
        for(int k=0;k<60;k++) if(cnt[k]&&((a[i]>>k)&1)) a[i]^=1LL<<k;
        tot^=a[i];
        add(a[i]);
    }
    ll sum=0;
    for(int i=0;i<60;i++) if(cnt[i]) sum+=1LL<<i;
    ll ans=0;
    for(auto x:basis) ans^=x;
    pf1ll(sum+ans*2);
    return 0;
}
///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;

class Program {
    static int Main(string[] args) {
        string v = Console.ReadLine();
        
        int a = int.Parse(v.Split(' ')[0]);
        int b = int.Parse(v.Split(' ')[1]);
        int c = int.Parse(v.Split(' ')[2]);

        int cnt = 0;
        for (int i = a; i <= b; i++) {
            if (c % i == 0) { cnt++; }
        }

        Console.WriteLine(cnt);

        return 0;
    }
}

Measured memory_bytes: 9188
#define _USE_MATH_DEFINES 
#include <cmath>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<vector>
#define rep(i,start,n) for(int i=start;i<n;i++)
#define And &&
#define Or ||
#define Lb cout<<endl
using namespace std;

int main(void) {
	int n, m; cin >> n >> m;
	vector<vector<int> > a(n, vector<int>(m));
	vector<int> b(m);
	vector<long long> c(n);
	//????????????
	rep(i, 0, n) {
		rep(j, 0, m) {
			cin >> a[i][j];
		}
	}
	
	rep(i, 0, m) {
		cin >> b[i];
	}

	rep(i, 0, n) {
		c[i] = 0;
		rep(j, 0, m) {
			c[i] += a[i][j] * b[j];
		}
	}

	rep(i, 0, n) {
		cout << c[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> pint;
#define rep(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};

int main(){
	ll n,k=1;
	cin>>n;
	rep(i,n){
		k*=(i+1);
	}
	cout<<k<<endl;
	return 0;
}

Measured memory_bytes: 0
import math
A, B = map(int, input().split())

x_min_A = A / 0.08
x_Max_A = (A + 1) / 0.08
x_min_B = B / 0.10
x_Max_B = (B + 1) / 0.10

x_min = max(x_min_A, x_min_B)
x_Max = min(x_Max_A, x_Max_B)

x = math.ceil(x_min)
if x < x_Max:
  print(x)
else:
  print(-1)

Measured memory_bytes: 38488
#include<bits/stdc++.h>
#define N 100009
#define M 3000009
using namespace std;

int n,m,cnt,rt,trtot,H,W,ls[M],rs[M]; bool bo[M];
struct node{ int x,y; }a[N];
bool cmp(node u,node v){ return u.x<v.x; }
int calc(int x,int y){
	if (x && y && x<H && y<W) return 0;
	if (!x) return y+1;
	if (y==W) return x+W+1;
	if (x==H) return W+H+W-y+1;
	return W+H+W+H-x+1;
}
void ins(int &k,int l,int r,int x){
	if (!k) k=++trtot;
	if (l==r) return;
	int mid=l+r>>1;
	if (x<=mid) ins(ls[k],l,mid,x); else ins(rs[k],mid+1,r,x);
}
bool getsum(int k,int l,int r,int x,int y){
	if (!k) return 0;
	if (x<=l && r<=y) return 1;
	int mid=l+r>>1; bool ans=0;
	if (x<=mid) ans=getsum(ls[k],l,mid,x,y);
	if (y>mid) ans|=getsum(rs[k],mid+1,r,x,y);
	return ans;
}
int main(){
	scanf("%d%d%d",&H,&W,&n);
	int i,x1,x2,y1,y2;
	for (i=1; i<=n; i++){
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		a[++cnt]=(node){calc(x1,y1),calc(x2,y2)};
		if (!a[cnt].x || !a[cnt].y) cnt--;
		if (a[cnt].x>a[cnt].y) swap(a[cnt].x,a[cnt].y);
	}
	sort(a+1,a+cnt+1,cmp);
	n=H+W<<1;
	for (i=1; i<=cnt; i++){
		if (getsum(rt,1,n,a[i].x,a[i].y)){
			puts("NO"); return 0;
		}
		ins(rt,1,n,a[i].y);
	}
	puts("YES");
	return 0;
}


Measured memory_bytes: 13312
#include<iostream>
using namespace std;
bool binary_search(int*,int,int,int);
int main(void){
    int n,q,*A,T,count=0;
    cin >> n;
    A = new int[n];
    for(int i=0;i<n;i++){
        cin >> A[i];
    }
    cin >> q;
    for(int i=0;i<q;i++){
        cin >> T;
        if(binary_search(A,n,q,T)){
            count++;
        }
    }
    cout << count << endl;
    delete[] A;
    return 0;
}
 bool binary_search(int *A,int n,int q,int T){
    int right = n;
    int left = 0;
    while(right - left>0){
        if(A[(right+left)/2]<T){
        left = (right+left)/2 + 1;
        }else if(A[(right+left)/2]>T){
        right = (right+left)/2;
        }else{
            return true;
        }
    }
    return false;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
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;
}
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    char c;
    cin >> c;
    char f[] = {'a', 'i', 'u', 'e', 'o'};
    for(int i = 0; i < 5; i++) {
        if(c == f[i]) {
            cout << "vowel" << endl;
            return 0;
        }
    }
    cout << "consonant" << endl;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int N, M;
int A[100010];
ll B[100010];
map<ll, int> mp;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    B[i+1] = A[i] + B[i];
  }

  mp[0]++;

  ll ans = 0;
  for (int i = 1; i <= N; i++) {
    B[i] %= M;
    ans += mp[B[i]];
    mp[B[i]]++;
  }
  cout << ans << endl;

  return 0;
}

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



int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a,b,x;cin>>a>>b>>x;a+=x;b+=x;
    cout<<b/x-(a-1)/x<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

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

int main() {
    long long ans = 0, n;
    std::cin >> n;
    for (int a=1; a<=n; ++a) {
        for (int b=1; b<=n; ++b) {
            for (int c=1; c<=n; ++c) {
                ans += gcd(a, gcd(b, c));
            }
        }
    }
    std::cout << ans << std::endl;
    return 0;
}



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

int a[12][12];
int main()
{
    int n,m,x;
    cin>>n>>m>>x;

    //参考書の値段
    vector <int> c(n);
    //各参考書の各スキル値
    
    for(int i=0;i<n;i++)
    {
        cin>>c[i];
        for(int j=0;j<m;j++)
        {
            cin>>a[i][j];
        }
    }

    

    int costMin=1001001001;
    //bit全探索
    for(int bit=0;bit<(1<<n);bit++)
    {
        int cost = 0;
        vector <int> d(m);
        for(int i=0;i<n;i++)
        {
            if(bit&(1<<i))
            {
                cost+=c[i];
                for(int j=0;j<m;j++)
                {
                    d[j]+=a[i][j];
                }
            }
        }
        bool flag = true;

        for(int k=0;k<m;k++)
        {
            if(d[k]<x)
            {
                flag = false;
            }
        }

        if(flag)
        {
            costMin=min(costMin,cost);
        }
    }

    if(costMin==1001001001)
    {
        cout<<-1<<endl;
    }
    else
    {
        cout<<costMin<<endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;
#define FIX cout << fixed << setprecision(15)

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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

using ll = long long;
using Graph = vector<vector<int>>;

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN(n);
  Vi A(n*3);
  VIN(A)
  RSORT(A);
  REP(i,n*2){
    if(i%2==1) z += A[i];
  }
  OUT(z);
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
typedef long long L;
using namespace std;
  
#define N 100005
#define U [N]={}
map<L,L> path[N];
L par U,dep U,siz U,hev U,cst U,add U,pos U,hl_par U,bit U,
k,n,q,a,b,c,i,p,r;
char s[5];
void dfs(L a){
    siz[a]=1;
    for(map<L,L>::iterator I=path[a].begin();I!=path[a].end();I++){
        L d=I->first;
        if(d==par[a]) continue;
        par[d]=a;
        dep[d]=dep[a]+1;
        cst[d]=I->second;
        dfs(d);
        siz[a]+=siz[d];
        if(!hev[a] || siz[hev[a]]<siz[d])
            hev[a]=d;
    }
}
    
L edgecost(L a){
    L ret=add[a]+add[par[a]]+cst[a];
    return ret%k ? ret : 0;
}
    
L sum(L i){
    L ret=0;
    while(i){
        ret+=bit[i];
        i-=i&-i;
    }
    return ret;
}
void S(L i, L x){
    x=edgecost(x)-sum(i+1)+sum(i);
    i++;
    while(i<N){
        bit[i]+=x;
        i+=i&-i;
    }
}
  
main(){
    for(cin>>n>>k;i<n-1;i++)
        cin>>a>>b>>c,
        path[a][b]=path[b][a]=c;
    dfs(0);
    
    for(c=i=0;i<n;i++){
        if(!i|hev[par[i]]-i)
        for(a=i;!c|a;a=hev[a]){
            pos[a]=c++;
            hl_par[a]=i;
        }
    }
     
    for(i=0; i<n; i++)
        S(pos[i],hev[i]);
     
    cin >> q;
    for(i=0; i<q; i++){
        cin>>s>>a>>b;
        if(*s&2){
            for(c=0;p=hl_par[a],r=hl_par[b],p-r;a=par[p])
                dep[p]<dep[r]?swap(p,r),swap(a,b),0:0,
                c+=sum(pos[a])-sum(pos[p])+edgecost(p);
            cout<<c+abs(sum(pos[a])-sum(pos[b]))<<endl;
        }else{
            add[a]+=b;
            S(pos[a],hev[a]);
            if(a)S(pos[a]-1,a);
        }
    }
}

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

using namespace std;
#define int long long
#define pb push_back
#define fio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define vin(vec) for(auto &elem:vec)cin>>elem
#define vi vector<int>
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.first<<','<< P.second<<')';}
template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}
#define show(x) cout<<#x<<" : "<<x<<'\n';


signed main(){
	fio;
	int t=1;
	// cin>>t;
	while(t--){
		int n;
		cin>>n;
		vector<vector<int>> v(n);
		for(int i=0; i<n; i++){
			for(int j=0; j<3; j++){
				int temp; cin>>temp;
				v[i].pb(temp);
			}
		}
		vector<vector<int>> dp(n, vi(3,0));
		for(int i=0; i<3; i++){
			dp[n-1][i]=v[n-1][i];
		}
		// dp[n-1] = max({v[n-1][0], v[n-1][1], v[n-1][2]});
		for(int i=n-2; i>=0; i--){
			for(int j=0; j<3; j++)
				for(int k=0; k<3; k++)
					if(k!=j)
						dp[i][j]=max(dp[i][j], v[i][j] + dp[i+1][k]);
		}
		cout<<max(dp[0][0], max(dp[0][1], dp[0][2]))<<'\n';
	}
}

Measured memory_bytes: 15584
import collections
S = collections.deque(list(input()))
Q = int(input())
spin = False
for i in range(Q):
    temp = list(input().split())
    if temp[0] == "1":
        spin = not spin
    else:
        if spin:
            if temp[1] == "1":
                S.append(temp[2])
            else:
                S.appendleft(temp[2])
        else:
            if temp[1] == "1":
                S.appendleft(temp[2])
            else:
                S.append(temp[2])

res = ""
if spin:
    S.reverse()
    print("".join(S))
else:
    print("".join(S))


Measured memory_bytes: 74088
#include <iostream>
#include <string>

using namespace std;

int main() 
{
  int cnt;
  cin >> cnt;
  
  string str;
  cin >> str;

  if(str.size()<= cnt)
  {
      cout << str << endl;
      return 0;
  }  
  else
  {
    str.replace(str.begin()+cnt,str.end(),"...");
    cout << str << endl;
    return 0;
  }
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <vector>
#define N 100005
using namespace std;

typedef long long ll;
ll n, ans[N];
bool v[N];
vector<ll> gr[N], ga[N];

void f(ll p, ll q) {
	ll i;
	if (v[p]) return;
	v[p] = 1;
	if (q % 2 == 0) ans[p] = 1;
	for (i = 0; i < gr[p].size(); i++) {
		f(gr[p][i], q + ga[p][i]);
	}
}

int main()
{
	ll i, t1, t2, t3;
	cin >> n;
	for (i = 1; i < n; i++) {
		scanf("%lld %lld %lld", &t1, &t2, &t3);
		gr[t1].push_back(t2); ga[t1].push_back(t3);
        gr[t2].push_back(t1); ga[t2].push_back(t3);
	}
	f(1, 0);
	for (i = 1; i <= n; i++) printf("%d ", ans[i]);
    return 0;
}

Measured memory_bytes: 14080
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ordered_set tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update>

using namespace __gnu_pbds;
using namespace std;

ll mod = 1e9+7;

ll add(ll a, ll b) { return (a % mod + b % mod) % mod; }
ll mul(ll a, ll b) { return (a % mod * b % mod) % mod; }
ll debug(vector<int> a) { for(int i: a) cout << i << " "; return puts("\n"), 0;}

ll power(ll base, ll exp) {
    ll res = 1;
    while(exp) {
        if(exp&1) res = mul(res, base);
        base = mul(base, base);
        exp >>= 1;
    }
    return res;
}

ll inv(ll p) {
    return power(p, mod-2);
}


int main() {
    fastio
    int n; string s;
    cin >> n >> s;
    string ans = "";
    for(char c: s) {
        int d = c - 'A';
        d = (d + n)%26;
        ans = ans + (char)('A' + d); 
    }

    cout << ans;
}

Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>
#define LHX_BAOLING {puts("Impossible"); return 0;}
using namespace std;
const int N=100010,M=110;
int n,m;
int a[M];
int p1,p2;
int b[N],bcnt;
void readData(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++) scanf("%d",&a[i]);
}
bool judge(){
	p1=p2=-1;
	for(int i=1;i<=m;i++)
		if(a[i]&1){
			if(p1==-1)
				p1=i;
			else if(p2==-1)
				p2=i;
			else return false;
		}
	return true;
}
void construct(){
	if(p1!=-1){
		swap(a[1],a[p1]);
		p1=1;
	}
	if(p2!=-1){
		swap(a[p2],a[m]);
		p2=m;
	}
	for(int i=1;i<=m;i++) printf("%d ",a[i]);
	puts("");
	if(m==1){
		if(a[1]&1){
			if(a[1]-1)
				b[++bcnt]=a[1]-1;
			b[++bcnt]=1;
		}
		else{
			if(a[1]-2)
				b[++bcnt]=a[1]-2;
			b[++bcnt]=2;
		}
	}
	else{
		if(a[1]&1){
			if(a[1]-1)
				b[++bcnt]=a[1]-1;
		}
		else{
			if(a[1]-2)
				b[++bcnt]=a[1]-2;
			b[++bcnt]=1;
		}
		for(int i=2;i<m;i++)
			b[++bcnt]=a[i];
	}
	int sum=0;
	for(int i=1;i<=bcnt;i++) sum+=b[i];
	if(n-sum){
		int x=n-sum;
		if(x&1){
			if(x-1)
				b[++bcnt]=x-1;
			b[++bcnt]=1;
		}
		else
			b[++bcnt]=x;
	}
	printf("%d\n",bcnt);
	for(int i=1;i<=bcnt;i++) printf("%d ",b[i]);
	puts("");
}
int main(){
	readData();
	if(!judge())
		LHX_BAOLING;
	construct();
	return 0;
}


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

using namespace std;

int main()
{
	int N, W;
	cin >> N >> W;
	vector<long long>w(N + 1), v(N + 1);
	vector<vector<long long>> dp(N+1,vector<long long>(W+1));
	for (int k = 0; k < N; k++)
	{

		cin >> w[k] >> v[k];
	}
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j <= W; j++)
		{
			if (j < w[i])
				dp[i + 1][j] = dp[i][j];
			else dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
		}
	}
	cout << dp[N][W];
}




Measured memory_bytes: 80256
#include <algorithm>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

using vll = vector<ll>;

void solve();

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

  solve();

  return 0;
}

#define ini(...)   \
  int __VA_ARGS__; \
  in(__VA_ARGS__)

#define inl(...)  \
  ll __VA_ARGS__; \
  in(__VA_ARGS__)

#define ins(...)      \
  string __VA_ARGS__; \
  in(__VA_ARGS__);

void in() {}
template <typename T, class... U>
void in(T& t, U&... u) {
  cin >> t;
  in(u...);
}

void out() {
  cout << endl;
}
template <typename T, class... U>
void out(const T& t, const U&... u) {
  cout << t;
  if (sizeof...(u))
    cout << " ";
  out(u...);
}

#define rep(i, n) for (long long i = 0; i < n; i++)

void solve();
#ifndef ONLINE_JUDGE
#include "./lib.hpp"
#endif

void solve() {
    ini(W, a, b);
    if (a > b)
        swap(a, b);

    if (a + W < b)
        out(b - a - W);
    else
        out(0);
}


Measured memory_bytes: 3600
import Data.Array.IO
import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import Control.Monad
import Control.Applicative

type UnionFindIO = IOArray Int (Int,Int)

newUFIO :: Int -> IO UnionFindIO
newUFIO n = newListArray (1,n) (zip [1..n] (repeat 1))
 
findUFIO :: UnionFindIO -> Int -> IO Int
findUFIO uf x = do
  (parent,size) <- readArray uf x
  if parent == x then
    return x
    else do
    next <- findUFIO uf parent
    writeArray uf x (next,size)
    return next
 
sameUFIO :: UnionFindIO -> Int -> Int -> IO Bool
sameUFIO uf x y = do
  xx <- findUFIO uf x
  yy <- findUFIO uf y
  return $ xx == yy
 
uniteUFIO :: UnionFindIO -> Int -> Int -> IO ()
uniteUFIO uf x y = do
  xx <- findUFIO uf x
  yy <- findUFIO uf y
  (_,xs) <- readArray uf xx
  (_,ys) <- readArray uf yy

  if xx == yy then
    return ()
    else if xs < ys then do
    writeArray uf xx (yy,0)
    else if xs > ys then do
    writeArray uf yy (xx,0)
    else do
    writeArray uf yy (xx,0)
    writeArray uf xx (xx,xs+1)

listToTuple2 [a,b] = (a,b)
modifyArray arr i f = readArray arr i >>= \x -> writeArray arr i (f x)
readIntBS = fst . fromJust . BS.readInt

main = do
  (n,m) <- listToTuple2 . map readIntBS . BS.words <$> BS.getLine :: IO (Int,Int)
  ps <- map readIntBS . BS.words <$> BS.getLine :: IO [Int]
  uf <- newUFIO n

  arr <- newArray (1,n) 0 :: IO (IOArray Int Int)
  forM_ (zip [1..] ps) $ \(i,p) -> do
    writeArray arr p i
  
  
  replicateM m $ do
    (x,y) <- listToTuple2 . map readIntBS . BS.words <$> BS.getLine :: IO (Int,Int)
    uniteUFIO uf x y

  c <- forM [1..n] $ \i -> do
    j <- readArray arr i
    isSame <- sameUFIO uf i j
    return $ if isSame then 1 else 0

  print $ sum c


Measured memory_bytes: 26108
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_MOD			1000000007								// 除数(10の9乗+7)
#define D_SIZE_MAX		2005									// 最大サイズ

// 内部変数
static FILE *szpFpI;											// 入力
static int si1S[D_SIZE_MAX];									// 配列S
static int siSCnt;												// 配列S数
static int si1T[D_SIZE_MAX];									// 配列T
static int siTCnt;												// 配列T数
static int si2PCnt[D_SIZE_MAX][D_SIZE_MAX];						// パターン数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 和 - 取得
int
fGetModSum(
	int piVal1					// <I> 値１
	, int piVal2				// <I> 値２
)
{
	return (piVal1 + piVal2) % D_MOD;
}

// 実行メイン
int
fMain(
)
{
	int i, j;
	char lc1Buf[1024];

	// データ - 初期化
	memset(si2PCnt, 0, sizeof(si2PCnt));

	// 配列数 - 取得
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d%d", &siSCnt, &siTCnt);

	// 配列 - 取得
	for (i = 1; i <= siSCnt; i++) {
		fscanf(szpFpI, "%d", &si1S[i]);
	}
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	for (i = 1; i <= siTCnt; i++) {
		fscanf(szpFpI, "%d", &si1T[i]);
	}
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);

	// パターン数 - セット
	for (i = 1; i <= siSCnt; i++) {
		for (j = 1; j <= siTCnt; j++) {
			si2PCnt[i][j] = fGetModSum(si2PCnt[i - 1][j], si2PCnt[i][j - 1]);
			if (si1S[i] == si1T[j]) {
				si2PCnt[i][j] = fGetModSum(si2PCnt[i][j], 1);
			}
			else {
				si2PCnt[i][j] = fGetModSum(si2PCnt[i][j], -si2PCnt[i - 1][j - 1]);
			}
		}
	}

	return fGetModSum(si2PCnt[siSCnt][siTCnt], D_MOD + 1);
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// １行出力
	sprintf(lc1Buf, "%d\n", liRet);
	fOutLine(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



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

int main () {
  char x , y ;
  cin >> x >> y ;
  
  if ( x == y ) {
    cout << "=" << endl ;
  } else if ( x >= y ){
    cout << ">" << endl ;
  } else {
    cout << "<" << endl ;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
	char a[100],b[100],c[100];
	while(scanf("%s%s%s",&a,&b,&c) != EOF)
	{
		printf("A");
		printf("%c",b[0]);
		printf("C\n");
	}
	return 0;
}

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


int main(){
    int N,M; cin>>N>>M;
    int x;
    priority_queue<int> q;
    long long int sum=0;
    for(int i=0;i<N;i++){
        cin>>x;
        q.push(x);
    }
    while(M){
        x=q.top()/2;
        q.pop();
        q.push(x);
        M--;
    }
    while(!q.empty()){
        sum=sum+q.top();
        q.pop();
    }
    cout<<sum;

    return 0;
}

Measured memory_bytes: 892
// YOU THINK YOU KNOW ME.//


#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
#define int                      long long
#define MOD                     1000000007
#define inf                     9e18
#define ld                      long double
#define countbit                __builtin_popcount
#define loop(i,a,n)				for(int i=a;i<n;i++)
#define pb                      push_back
#define pf                      push_front
#define mp                      make_pair
#define f                       first
#define s                       second
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define boost                   ios_base::sync_with_stdio();cin.tie(0);cout.tie(0);
#define cases                   int tests;cin>>tests;while(tests--)
#define all(s)                  s.begin(),s.end()
#define line                    cout<<endl;
#define watch(x)                cout<<(#x)<<" is "<<x<<endl
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rich_set;
bool isprime(int n){if(n==1)return false;if(n==2)return true;for(int i=2;i<=sqrt(n);i++){if(n%i==0){ return false;}}return true;}
int poww(int b,int e){if(e==0)return 1;else if(e%2==0){int a=pow(b,e/2);return a*a;}else {int a=pow(b,e/2);return b*a*a;}}
int powm(int x,int y,int m=MOD){x=x%m;int res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
int modInverse(int a, int m=MOD) { return powm(a, m-2, m);}
void print(vector<int>v){for(int i=0;i<v.size();i++){cout<<v[i]<<" ";}}
void print(int arr[]){int size = *(&arr + 1) - arr; for(int i=0;i<size;i++){cout<<arr[i]<<" ";}}
string to_bin(int n){string res="";int i=0;while(n>0){if(n%2==1){res=res+'1';}else{res=res+'0';}n/=2;i++;}reverse(all(res));return res;}
int to_dec(string s){int n=s.size(),ans=0,temp=1;for(int i=n-1; i>=0; i--){int x=s[i]-'0';ans+=x*temp;temp*=2;}return ans;}
void result(bool f){if(f)cout<<"YES"<<endl;else cout<<"NO"<<endl;}



void solve(){
	int n;
    cin>>n;
    int arr[n];
    int k;
    cin>>k;
    loop(i,0,n){
        cin>>arr[i];
    }
    int dp[n+5];
    dp[0]=0;
    for(int i=1;i<n;i++){
        dp[i]=inf;
        int x=inf;
        loop(j,max(i-k,0ll),i){
             x = min(dp[i],abs(arr[i]-arr[j])+dp[j]);
            dp[i]=x;
        }
        dp[i]=x;
    }
    cout<<dp[n-1]<<endl;
}
int32_t main(){
	boost
  //cases
	solve();	
	
	//return 0;
}

Measured memory_bytes: 1792
def main():
	# n,m = map(int,input().split())
	n = int(input())
	# s = str(input())
	# a = list(map(int,input().split()))
	# l = [list(map(int, input().split())) for _ in range(n)]
	ans = 0
	for i in range(1,10):
		if n / i == int(n/i) and int(n/i) < 10:
			# print("i = {}".format(i))
			# print(n//i)
			# print(int(n//i))
			ans = 1
	if ans == 1:
		print("Yes")
	else:
		print("No")
	


if __name__ == '__main__':
	main()

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

int main(){
    int n;
    cin >> n;
    int count = 0;
    vector<int> vec(n);
    vector<int> vec2;
    for (int i = 0; i < n; i++){
        cin >> vec.at(i);
    }
    for (int j = 0; j < n; j++){
        vec2.push_back(vec.at(j));
        if (vec2.at(0) >= vec2.at(j)){
            swap(vec2.at(0), vec2.at(j));
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 2168
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
#define INF 9e18
const int maxn = 4e5 + 10;
struct road{
	int v;
	int to;
	int next;
}r[maxn];
long long dis[maxn];
int head[maxn],cnt;
bool vis[maxn];
void inti(){
	memset(head, -1, sizeof(head));
	for(int i = 0; i < maxn; ++i){
		dis[i] = INF;
	}
	memset(vis, false, sizeof(vis));
	cnt = 0;
}
void build(long long s, long long e, long long w){
	r[cnt].v = w;
	r[cnt].to = e;
	r[cnt].next = head[s];
	head[s] = cnt++;
}
void spfa(long long s){
	queue<int>q;
	int end, i, top;
	q.push(s);
	vis[s] = true;
	dis[s] = 0;
	while(!q.empty()){
		top = q.front();
		q.pop();
		vis[top] = false;
		for(i = head[top]; i != -1; i = r[i].next){
			end = r[i].to;
			if(dis[end] > dis[top] + r[i].v){
				dis[end] = dis[top] + r[i].v;
				if(!vis[end]){
					q.push(end);
					vis[end] = true;
				}
			}
		}
	}
}
int main()
{
	long long n, s, e, w, q, k, i, a, b;
	scanf("%lld",&n);
	inti();
	for(i = 1; i < n; ++i){
		scanf("%lld %lld %lld", &s, &e, &w);
		build(s, e, w);
		build(e, s, w);
	}
	scanf("%lld %lld", &q, &k);
	spfa(k);
	for(i = 1; i <= q; ++i){
		scanf("%lld %lld", &a, &b);
		//cout << dis[a] << endl;
		printf("%lld\n",dis[a] + dis[b]);
	}
}

Measured memory_bytes: 9984
s_vec1 = input()
s_vec2 = input()
def abc_057_2(o,e):
    s_vec3 = []
    for i in range(0,len(e)):
        s_vec3.append(o[i])
        s_vec3.append(e[i])
    if len(o) == len(e):
        pass
    else:
        s_vec3.append(o[i+1])
    return(''.join(s_vec3))
print(abc_057_2(s_vec1,s_vec2))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i < n; ++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)
ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

void solve() {
  // main coding
  int n; cin>>n;
  vector<int> A(n);
  vector<int> rev(n);
  rep(i,n) cin>>A[i];
  rep(i,n) rev[A[i]-1]=i+1;
  rep(i,n) {
    if (i!=n-1) cout<<rev[i]<<' ';
    else cout<<rev[i]<<endl;
  }
}

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


Measured memory_bytes: 1664
#include<stdio.h>
int F[44];
int fibonacci(int n);
  int main(){
    int fib,n;
  scanf("%d",&n);
fib= fibonacci(n);
 printf("%d\n",fib);
 return 0;
}

int fibonacci(int n){
  int i;
  F[0]=1;
  F[1]=1;
  if(F[n]!=NULL)
    return F[n];
  for(i=2;i<n;i++){
    F[i]=F[i-2]+F[i-1];
  }
  return F[n]=F[n-2]+F[n-1];
}

Measured memory_bytes: 596
n=int(input())
a=[int(j)-1 for j in input().split()]
b=[int(j) for j in input().split()]
c=[int(j) for j in input().split()]
ans=sum(b)
for i in range(1,n):
    if a[i-1]+1==a[i]:
        ans+=c[a[i-1]]
print(ans)

Measured memory_bytes: 3064
# nCk 前処理メモ化
MOD = 998244353
N = 200000
@fac = [1, 1]
@inv = [1, 1]
@finv = [1, 1]

(2..N).each do |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
end

def nCk(n, k)
  return 0 if n < k || n < 0 || k < 0
  @fac[n] * (@finv[k] * @finv[n - k] % MOD) % MOD
end

def repeated_nCk(n, k)
  # 仕切りのイメージで
  nCk(n + k - 1, n - 1) % MOD
end

n, m, k = gets.split.map(&:to_i)
ans = m
memo = [ans]
(n - 1).times do |i|
  ans *= (m - 1)
  ans %= MOD
  memo[i + 1] = ans
end
1.upto(k) do |i|
  ans += memo[n - i - 1] * nCk(n - 1, i)
  ans %= MOD
end
puts ans % MOD


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

public class Main {
	// AtCoder Beginner Contest 079
	// https://atcoder.jp/contests/abc079/tasks
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		String ticket = sc.next();
		int[] tickets = new int[ticket.length()];
		
		for (int i = 0; i < ticket.length(); i++) {
			tickets[i] = ticket.charAt(i) - '0';
		}
		findTicket(tickets, "" + tickets[0], 1, tickets[0]);
	}
	
	private static void findTicket(int[] nums, String s, int curr, int sum) {
		if (s.length() == 7) {
			if (sum == 7) {
				System.out.println(s + "=7");
				System.exit(0);
			} 
		} else {
			if (curr < nums.length) {
				findTicket(nums, s + "+" + nums[curr], curr+1, sum + nums[curr]);
				findTicket(nums, s + "-" + nums[curr], curr+1, sum - nums[curr]);
			}
		}
		
	}
	
	
	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine()); 
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try{ 
                str = br.readLine(); 
            } catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
}


Measured memory_bytes: 23124
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.System.in;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        String[] inputs = reader.readLine().split(" ");
        int X = Integer.parseInt(inputs[0], 16);
        int Y = Integer.parseInt(inputs[1], 16);
        if (X == Y) {
            System.out.println("=");
        } else if (X < Y) {
            System.out.println("<");
        } else {
            System.out.println(">");
        }
    }
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define RALL(a)     (a).rbegin(),(a).rend()
#define PRINT(a)   cout << (a) << endl

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second

#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

using ll = long long int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

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 int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

int main(){
  int x;
  cin >> x;
  cout << (x==0 ? 1 : 0) << endl;
}



Measured memory_bytes: 3632
"""
author : halo2halo
date : 12, Jan, 2020
"""

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

a, b = map(int, readline().split())
print(b if a >= 13 else b // 2 if a >= 6 else 0)


Measured memory_bytes: 3060
fun intList() = readLine()?.split(" ")?.map(String::toInt) ?: TODO()
fun longList() = readLine()?.split(" ")?.map(String::toLong) ?: TODO()
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val a = longList()
    val q = readLine()?.toInt() ?: return
    var t: Long = a.sum()
    val map = hashMapOf<Long, Int>()
    a.forEach { i ->
        map[i] = map[i]?.let { it + 1 } ?: 1
    }
    buildString {
        repeat(q) {
            val (b, c) = longList()
            val bb = map[b] ?: 0
            val cc = map[c] ?: 0
            val d = c - b
            t += d * bb
            map[b] = 0
            map[c] = cc + bb
            appendln(t)
        }
    }.let {
        println(it.trimIndent())
    }
}


Measured memory_bytes: 84576
#include<stdio.h>
#include<math.h>

int main() {
	double x1,y1,x2,y2;
	scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
	printf("%f\n",sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)));

	return 0;
}

Measured memory_bytes: 652
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  ll N, A, B, C, D, E;
  cin >> N >> A >> B >> C >> D >> E;
  ll X = min(A, min(B, min(C, min(D, E))));
  if (N%X==0) cout << N/X+4 << endl;
  else cout << N/X+5 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n = 0, pos = 0, ans = 0, dit = -1;
deque<pair<int, int> > peo;
inline int myabs(int x) { return (x < 0? -x: x); }
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cin >> n >> pos;
	for(int i = 1; i <= n; i++) {
		int x = 0, y = 0;
		cin >> x >> y;
		peo.push_back(make_pair(x, y));
	}
	if((peo.begin() -> second) >= (peo.rbegin() -> second)) dit = 1;
	else dit = 0;
	while(true){
		pair<int, int> &a = *(peo.begin()), &b = *(peo.rbegin());
		if(a.first >= pos) { ans += (b.first - pos); break; }
		if(b.first <= pos) { ans += (pos - a.first); break; }
		if(a.second >= b.second) {
			a.second += b.second;
			if(dit) ans += (b.first - a.first);
			peo.pop_back();
			dit = 0;
		} else {
			b.second += a.second;
			if(!dit) ans += (b.first - a.first);
			peo.pop_front();
			dit = 1;
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
using ll = long long;

int MARCH[5] = {0};
int C1[10]   = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2};
int C2[10]   = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3};
int C3[10]   = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    if (s[0] == 'M') MARCH[0]++;
    if (s[0] == 'A') MARCH[1]++;
    if (s[0] == 'R') MARCH[2]++;
    if (s[0] == 'C') MARCH[3]++;
    if (s[0] == 'H') MARCH[4]++;
  }
  ll total = 0;
  for (int i = 0; i < 10; i++)
    total += 1LL * MARCH[C1[i]] * MARCH[C2[i]] * MARCH[C3[i]];
  cout << total << '\n';
  return 0;
}


Measured memory_bytes: 256
import copy


class Dice:
    def __init__(self, a, b, c, d, e, f):
        self.top = a
        self.front = b
        self.right = c
        self.left = d
        self.behind = e
        self.bottom = f

    def S(self):
        self.top, self.front, self.behind, self.bottom = self.behind, self.top, self.bottom, self.front

    def N(self):
        self.behind, self.top, self.bottom, self.front = self.top, self.front, self.behind, self.bottom

    def E(self):
        self.top, self.bottom, self.left, self.right = self.left, self.right, self.bottom, self.top

    def W(self):
        self.left, self.right, self.bottom, self.top = self.top, self.bottom, self.left, self.right

    def spin(self):
        self.left, self.behind, self.right, self.front = self.front, self.left, self.behind, self.right

    def __eq__(self, _dice2):
        dice2 = copy.deepcopy(_dice2)
        for i in range(4):
            if self._eqaul(dice2):
                return True
            dice2.spin()
        dice2 = copy.deepcopy(_dice2)
        dice2.N()
        dice2.N()
        for i in range(4):
            if self._eqaul(dice2):
                return True
            dice2.spin()
        dice2 = copy.deepcopy(_dice2)
        dice2.N()
        for i in range(4):
            if self._eqaul(dice2):
                return True
            dice2.spin()
        dice2 = copy.deepcopy(_dice2)
        dice2.E()
        for i in range(4):
            if self._eqaul(dice2):
                return True
            dice2.spin()
        dice2 = copy.deepcopy(_dice2)
        dice2.W()
        for i in range(4):
            if self._eqaul(dice2):
                return True
            dice2.spin()
        dice2 = copy.deepcopy(_dice2)
        dice2.S()
        for i in range(4):
            if self._eqaul(dice2):
                return True
            dice2.spin()
        return False



    def _eqaul(self, dice2):
        return self.front == dice2.front and self.behind == dice2.behind and self.left == dice2.left and self.right == dice2.right and self.top == dice2.top and self.bottom == dice2.bottom

    def __repr__(self):
        return ",".join([str(object=i) for i in (self.top,self.front,self.right,self.left,self.behind,self.bottom)])

dice1 = Dice(*[int(i) for i in input().split(" ")])
dice2 = Dice(*[int(i) for i in input().split(" ")])

if(dice1 == dice2):
    print("Yes")
else:
    print("No")



Measured memory_bytes: 6360
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = Integer.parseInt(sc.next());
    char in[][] = new char[N][N];
    for (int i = 0; i < N; i++) {
      String str = sc.next();
      for (int j = 0; j < N; j++) {
        in[i][j] = str.charAt(j);
      }
    }
    int count = 0;
    boolean errorFlag = false;
    for (int t = 0; t < N; t++) {
      errorFlag = false;
      for (int i = 1; i < N; i++) {
        for (int j = 0; j < i; j++) {
          if (in[i][(j + t) % N] != in[j][(i + t) % N]) {
            errorFlag = true;
            break;
          }
        }
        if (errorFlag) {
          break;
        }
      }
      if (!errorFlag) {
        count++;
      }
    }

    System.out.println(count * N);
  }
}

Measured memory_bytes: 28748
#include <bits/stdc++.h>
using namespace std;
int main(){
//    vector<int> mas(3);
//    for(int i = 0; i < mas.size(); i++){
//        cin >> mas.at(i);
//    }
    string mas;
    cin >> mas;
    int count = 0;
    for(int i = 0; i < mas.size(); i++){
        if(mas.at(i) == '1'){
            count++;
        }
    }
    cout << count << endl;
}

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

using namespace std;

struct Point
{
    int x, y, h;
};

bool pcmp(const Point& l, const Point& r) { return l.h > r.h; }

int main(void)
{
    int N;
    int Cx, Cy, H;
    cin >> N;
    vector<Point> ps(N);
    auto i = ps.begin();
    for (auto &i: ps) cin >> i.x >> i.y >> i.h;
    sort(ps.begin(), ps.end(), pcmp);
    for (Cx = 0; Cx <= 100; Cx++)
    {
        for (Cy = 0; Cy <= 100; Cy++)
        {
            H = ps.begin()->h + abs(ps.begin()->x - Cx) + abs(ps.begin()->y - Cy);
            for (i = ps.begin() + 1; i != ps.end(); i++)
            {
                if (max(H - abs(i->x - Cx) - abs(i->y - Cy), 0) != i->h) break;
            }
            if (i == ps.end()) break;
        }
        if (i == ps.end()) break;
    }
    cout << Cx << " " << Cy << " " << H << endl;
    return 0;
}


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

using namespace std;

int main(){

	int n;
	while(cin>>n&&n!=0){
		vector<int> numList;
		for(int i = 0; i < n; i++){
			int tmp;
			cin>>tmp;
			if(numList.size()==0)
				numList.push_back(tmp);
			else if(numList[numList.size()-1]+1==tmp){
				numList.push_back(tmp);
			}
			else{
				if(numList.size()>=2){
					cout<<numList[0] << "-" << numList[numList.size()-1];
					cout<<" "<<flush;
				}
				else{
					cout<<numList[0]<<flush;
					cout<<" "<<flush;
				}
				numList.clear();
				numList.push_back(tmp);
			}
		}
		if(numList.size()>=2){
			cout<<numList[0] << "-" << numList[numList.size()-1];
		}
		else{
			cout<<numList[0];
		}
		cout<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <string.h>
#include <stdio.h>
#include <iostream>
#include <string>
#include <cstring>
#include <math.h>
#include <set>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

typedef long long ll;
#define INF 0x3f3f3f3f
#define ESP 1e-8
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
const double PI = acos(-1.0);

#define N 100005
struct Edge{
    int from, to, next;
}e[N*2];
int head[N], ecnt, n;

void add(int idx, int to){
    e[ecnt].from=idx, e[ecnt].to=to;
    e[ecnt].next=head[idx], head[idx]=ecnt++;
}

int d[2][N], c;
void dfs(int idx, int pa, int len){
    d[c][idx] = len;
    int i = head[idx];
    while(i != -1){
        if(e[i].to != pa)
            dfs(e[i].to, idx, len+1);
        i = e[i].next;
    }
}

int main(){
    // FILE *fp = freopen("out.txt", "w", stdout);
    // freopen("in.txt", "r", stdin);
    int i, x, y;
    while(scanf("%d", &n) != EOF){
        ecnt = 0;
        memset(head, -1, sizeof(head));
        for(i = 1; i < n; i++){
            scanf("%d%d", &x, &y);
            add(x, y), add(y, x);
        }
        c = 0, dfs(1, 0, 0);
        c = 1, dfs(n, 0, 0);
        x = 0;
        for(i = 1; i <= n; i++)
            if(d[0][i] <= d[1][i])
                x++;
        if(x > n - x)
            printf("Fennec\n");
        else
            printf("Snuke\n");
    }

    // fclose(fp);
    return 0;
}

Measured memory_bytes: 8448
#include <iostream>
using namespace std;
int main()
{
	int N;
	int a, b;

	cin >> N;
	a = N / 100;
	a = a * 100;

	b = N - a;

	if((N - 700) >= 0 && (N - 700) <= 99){
		cout << "Yes\n";
	}else if((b-70) >= 0 && (b-70) <=9){
		cout << "Yes\n";
	}else if((N - 7) % 10 == 0){
		cout << "Yes\n";
	}else {
		cout << "No\n";
	}
	
}







Measured memory_bytes: 3672