akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB(x) push_back(x)
#define MP make_pair
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<'Y'<<'e'<<'s'<<endl
#define coutn cout<<'N'<<'o'<<endl
#define coutY cout<<'Y'<<'E'<<'S'<<endl
#define coutN cout<<'N'<<'O'<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;
//cout<<fixed<<setprecision(15)<<

signed main(){
    int r; cin >> r;
    cout<<r*r<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int N = sc.nextInt();
		Set<Integer> set = new HashSet<Integer>();

		if(N==0){
			System.out.println(X);
			return;
		}
		if(N==100){
			if(X<=50){
				System.out.println(0);
				return;
			}else{
				System.out.println(101);
				return;
			}
		}

		for(int i=0; i<N; i++){
			set.add(sc.nextInt());
		}

		Integer abs = 100;
		Integer ptr = 0;

		for(int i=0; i<102; i++){
			if(set.contains(i)){
				continue;
			}
			Integer tmp = Math.abs(X-i);
			if(tmp<abs){
				abs = tmp;
				ptr = i;
			}
		}

		System.out.println(ptr);
		return;
	}
}

Measured memory_bytes: 35976
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
const long long INF = 1ll << 60;



int main() {
  ll n, d;
  cin >> n >> d;
  int ans = 0;
  ll D = d * d;
  rep(i,n){
    ll x, y; cin >> x >> y;
    ll dst = x * x + y * y;
    if(dst <= D) ans++;
  }
  cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3668
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

using namespace std;

int main(){
    int n;
    while(~scanf("%d",&n)){
        int pages[50];
        for(int i=0;i<n;i++){
            scanf("%d",pages+i);
        }

        vector<pair<int, int> > pset;
        for(int i=0;i<n;){
            int start = i;
            int end = i;
            for(int j=i+1;j<n;){
                if(abs(pages[j] - pages[j-1])>1){
                    i=j;
                    break;
                }
                else{
                    end = j;
                    j++;
                }
            }
            pset.push_back(make_pair(pages[start],pages[end]));
            i=end+1;
        }

        for(int i=0;i<pset.size();i++){
            if(pset[i].first != pset[i].second){
                printf("%d-%d%s",pset[i].first,pset[i].second,i==pset.size()-1 ? "\n" : " ");
            } else {
                printf("%d%s",pset[i].first,i==pset.size()-1 ? "\n" : " ");
            }
        }
    }
    return 0;
}

Measured memory_bytes: 0
var Digit;
(function (Digit) {
    var Counter = (function () {
        function Counter(a, b) {
            this.number = a + b;
        }
        Counter.prototype.count = function () {
            var digits = 1;
            var remain = this.number;
            while (true) {
                remain = Math.floor(remain / 10);
                if (remain <= 0) {
                    break;
                }
                digits++;
            }
            return digits;
        };
        return Counter;
    })();
    Digit.Counter = Counter;
})(Digit || (Digit = {}));
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (chunk) {
    chunk.trim().split('\n').forEach(function (lines) {
        var ab = lines.trim().split(' ');
        var digit = new Digit.Counter(+ab[0], +ab[1]);
        console.log(digit.count());
    });
});

Measured memory_bytes: 8776
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,a,b;
  cin>>n>>a>>b;
  ll x[n],inf=1LL<<50LL;
  for(ll i=0;i<n;i++) cin>>x[i];
  ll dp[n];
  fill(dp,dp+n,inf);
  dp[0]=0;
  for(ll i=0;i<n-1;i++) dp[i+1]=min(a*(x[i+1]-x[i]),b)+dp[i];
  //for(ll i=0;i<n-1;i++) cout<<dp[i]<<endl;
  cout<<dp[n-1]<<endl;
  return 0;
}


Measured memory_bytes: 1792
from math import atan,pi
a,b,x=map(int,input().split())
if a*a*b/2<=x:
    h=x/(a**2)
    c=(b-h)*2
    theta=atan(c/a)/2/pi*360
    print(theta)
else:
    c=2*x/b/a
    theta=atan(b/c)/2/pi*360
    print(theta)


Measured memory_bytes: 9376
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main() {
  
        ll n,m;
        cin>>n>>m;
        if(n==m)
        cout<<"Yes";
        else
        cout<<"No";
        
    
	return 0;
}

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

using namespace std;

const long long INF=0x3f3f3f3f3f3f3f3fLL;

struct Set
{
    vector<pair<long long, long long>> s;
    vector<pair<long long, long long>> t;
    long long find_by_first(long long x)
    {
        auto it=lower_bound(s.begin(), s.end(), make_pair(x+1, -1LL));
        if(it==s.begin())
            return INF;
        return (--it)->second;
    }
    long long find_by_second(long long x)
    {
        auto it=lower_bound(t.begin(), t.end(), make_pair(x+1, -1LL));
        if(it==t.begin())
            return INF;
        return (--it)->second;
    }
    void init()
    {
        sort(s.begin(), s.end());
        t.push_back(s[0]);
        for(int i=1; i<(int)s.size(); i++)
            if(s[i].second<t.back().second)
                t.push_back(s[i]);
        s=t;
        t.clear();
        for(auto& it: s)
            t.push_back({it.second, it.first});
        reverse(t.begin(), t.end());
    }
    void clear()
    {
        s.clear();
        t.clear();
    }
    void insert(long long x, long long y)
    {
        s.push_back({x, y});
    }
    size_t size()
    {
        return s.size();
    }
} s[131073];

int N;
long long X;
vector<int> adj[131073];
vector<int> d[131073];
int ok;

void dfs(int u)
{
    if(adj[u].empty())
    {
        s[u].clear();
        s[u].insert(0, 0);
        s[u].init();
        return;
    }
    int l=adj[u][0];
    int dl=d[u][0];
    int r=adj[u][1];
    int dr=d[u][1];
    dfs(l);
    dfs(r);
    if(s[l].size()>s[r].size())
        swap(l, r), swap(dl, dr);
    s[u].clear();
    long long L=X-dl-dr;
    for(auto& it: s[l].s)
    {
        long long v=s[r].find_by_first(L-it.second);
        if(v!=INF)
        {
            long long x=it.first+dl, y=v+dr;
            s[u].insert(x, y);
        }
        v=s[r].find_by_second(L-it.first);
        if(v!=INF)
        {
            long long x=v+dr, y=it.second+dl;
            s[u].insert(x, y);
        }
    }
    if(s[u].size()==0)
        ok=0;
    s[u].init();
}

int main()
{
    scanf("%d", &N);
    for(int i=2; i<=N; i++)
    {
        int a, b;
        scanf("%d%d", &a, &b);
        adj[a].push_back(i);
        d[a].push_back(b);
    }
    long long lo=0, mid, hi=131072LL*N;
    while(lo<hi)
    {
        X=mid=(lo+hi)/2;
        ok=1;
        dfs(1);
        if(ok)
            hi=mid;
        else
            lo=mid+1;
    }
    printf("%lld\n", lo);
    return 0;
}


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

using namespace std;
int main(){
    long a,sum=0;
    for(int i=0; i<3; i++){
       cin >> a;
       sum+=a;
    }
       if(sum>=22) cout << "bust" << endl;
       else cout << "win" << endl;
    return 0;
}

Measured memory_bytes: 3556
#include <iostream>

using namespace std;

string S;

bool match(int i, string t) {
  if (i + t.size() > S.size()) return false;
  for (int j = 0; j < t.size(); ++j) {
    if (S[i + j] != t[j]) return false;
  }
  return true;
}

bool dfs(int i) {
  return S.size() == i
         || match(i, "dreamer") && dfs(i + 7)
         || match(i, "eraser") && dfs(i + 6)
         || (match(i, "dream") || match(i, "erase")) && dfs(i + 5);
}

int main() {
  cin >> S;

  cout << (dfs(0) ? "YES" : "NO") << endl;
}


Measured memory_bytes: 7508
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


Q = int(input())
L = []
R = []
for i in range(Q):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)

n2017 = set()
c2017 = [0]
total = 0
for i in range(1, 10**5+1):
    if is_prime(i) and is_prime((i+1)//2):
        total += 1
    c2017.append(total)

for i in range(Q):
    l = L[i]
    r = R[i]
    ans = (c2017[r] - c2017[l-1])
    print(ans)


Measured memory_bytes: 12828
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <queue>
#include <stdarg.h>
#include <map>
#include <vector>
#include <algorithm>
#include <stack>
#include <iostream>
#include <numeric>
#include <set>

#define ll long long

using namespace std;

ll mod = 998244353;

void
solve() {
  ll n, s;
  cin>>n>>s;

  vector<ll> a(n, 0);
  for (int i=0; i<n; i++)
    cin>>a[i];

  vector<vector<ll>> dp(n+1, vector<ll>(s+1, 0));
  dp[0][0] = 1;

  for (int i=0; i<n; i++)
    for (int j=0; j<=s; j++) {
      dp[i+1][j] += 2 * dp[i][j];
      dp[i+1][j] %= mod;

      if (j + a[i] <= s) {
        dp[i+1][j+a[i]] += dp[i][j];
        dp[i+1][j+a[i]] %= mod;
      }
    }

  cout<<dp[n][s]<<endl;
}

int 
main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(0);

  int t = 1;
  //cin>>t;

  while (t > 0) {
    t--;
    solve();
  }

  return 0;
}

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

int main()
{
	int R, G, B;

	cin >> R >> G >> B;

	int ans = R * 100 + G * 10 + B;

	if (ans % 4 == 0) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF (1LL<<57)
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define whoami(x) cerr<<#x<<" "<<x<<"\n";
#define mp make_pair
#define ins insert
#define sz size

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;

struct h_llint {
  static uint64_t splitmix64(uint64_t x) {    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

struct h_pair{
  size_t operator()(const PLL&x)const{
    return hash<ll>()(((ll)x.ff)^(((ll)x.ss)<<32));
  }
};

typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;
typedef unordered_map<ll, int, h_llint> UMLI;
typedef unordered_map<ll, ll, h_llint> UMLL;
typedef unordered_map<PLL, int, h_pair> UMPI;
typedef unordered_map<PLL, ll, h_pair> UMPL;

int ar[MV];
ll arr[MV];

void solve(int T)
{
	int n;
	cin>>n;
	VI ax(n);
	for(auto &&u : ax)
	cin>>u;
	bool ok = 1;
	for(auto u : ax)
	{
		if(!(u & 1) && (u % 3) && (u % 5))
		{
			ok = 0;
			break;
		}
	}	
	if(ok)
	cout<<"APPROVED\n";
	else cout<<"DENIED\n";
	return;	
}

int main(void)
{
	FLASH();
	int T;
	T = 1;

// #ifndef ONLINE_JUDGE
// 	time_t time_t1, time_t2;
// 	time_t1 = clock();
// #endif

	while(T--)
	solve(T);

// #ifndef ONLINE_JUDGE
// 	time_t2 = clock();
// 	SETF();
// 	cout<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
// 	UNSETF();
// #endif

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(int& a){printf("%d",a);}
//void print(long long& a){printf("%lld",a);}
void print(double& a){printf("%.15lf",a);}
template<class T> void print(T& a){cout<<a;}
template<class T> void print(vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(Head& head, Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(T& a){cerr<<a;}
template<class T> void dprint(vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(Head& head, Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    int n,ans;
    while(scanf("%d",&n)!=EOF){
        ans=0;
        rep(i,10){
            rep(j,10){
                rep(k,10){
                    rep(l,10){
                        if(i+j+k+l==n)ans++;
                    }
                }
            }
        }
        out(ans);
    }
}


Measured memory_bytes: 3096
///Bismillahir Rahmanir Rahim
///Hello_World_Its_Rakib_Alam_Bappi
#include<bits/stdc++.h>
using namespace std;
///ascii for  A=65   and   a=97
#define		int 	long long
#define 		pb 	push_back
#define 		mp 	make_pair
#define 		pi 	2*acos(0.0)
#define 		loopi 	for(int i = 0 ; i <t ; i++)
#define 		loopj 	for(int j = 0 ; j < n ; j++)
#define 		backj 	for(int j = n-1 ; j >=0 ; j--)
#define 		vect 	vector<int>
#define 		vec_it 	vector<int>::iterator vi
#define 		mapp 	map<int,int>m
#define 		pairr 	pair<int,int>p
#define 		sett	set<int>s
#define 		set_it 	set<int>::iterator si
#define 		yes 	cout<<"YES"<<endl
#define 		no 	cout<<"NO"<<endl
#define 		xx 	first
#define 		xy 	second
main()
{
    /// freopen ("in.txt" , "r",  stdin) ;
    string st;
    int n,k,t,temp=0,cnt=0,x,y=0,sum=0;
    cin>>n;
    cout<<2*pi*n;
   /// cout<<sum;
    
}

Measured memory_bytes: 3816
# -*- coding: utf-8 -*-

def main():
    s = str(input())
    t = str(input())

    if len(s) == (len(t) - 1):
        if t.startswith(s):
            c = t[len(t) - 1]
            if  c.islower():
                print("Yes\n")
                return
    print("No\n")


if __name__ == '__main__':
    main()

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

int  num [10005];

void f(int n)
{
    int m = sqrt(n);
    rep(i,m) rep(j,m) rep(k,m)  
    {
        int x = i+1;
        int y = j+1;
        int z = k+1;
        int index = x*x + y*y + z*z + x*y + y*z + z*x;
        if(index < 10005) num[index]++;
    }
}

int main()
{
    int n;
    cin >> n;
    f(n);
    rep(i,n) cout << num[i+1] << endl;
    return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(a, b) << " " << max(0, a+b-n) << endl;
}

Measured memory_bytes: 256
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());
        int q = Integer.parseInt(sc.next());
        int[] ary = new int[n];
        for (int i = 0; i < n - 1; i++) {
            int a = Integer.parseInt(sc.next());
            int b = Integer.parseInt(sc.next());
            ary[b - 1] = a - 1;
        }
        long[] ansAry = new long[n];
        for (int i = 0; i < q; i++) {
            int p = Integer.parseInt(sc.next());
            int x = Integer.parseInt(sc.next());
            ansAry[p - 1] += x;
        }
        for (int i = 1; i < n; i++) {
            ansAry[i] += ansAry[ary[i]];
        }
        for (long node : ansAry) {
            System.out.print(node + " ");
        }
    }
}

Measured memory_bytes: 99000
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, a;
  bool flg[1000010];
  for(i = 0; i < 1000010; ++i) flg[i] = false;
  scanf("%lld", &a);
  for(i = 1; ; ++i) {
    if(flg[a]) {
      printf("%lld", i);
      return 0;
    }
    flg[a] = true;
    if(a & 1) a = 3 * a + 1;
    else a /= 2;
  }
  return 0;
}

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

int main() {    
    int r, c, q;
    cin >> r >> c >> q;

    int s1 = 0, s2 = r, s3 = 0, s4 = c;
    for (int i = 1; i <= q; ++i) {
        int x, y, a;
        cin >> x >> y >> a;
        if ( a == 1 ) s1 = max(s1, x);
        else if ( a == 2 ) s2 = min(s2, x);
        else if ( a == 3 ) s3 = max(s3, y);
        else if ( a == 4 ) s4 = min(s4, y);
    }

    if ( s2 <= s1 || s4 <= s3 ) cout << 0 << endl;
    else cout << abs(s1 - s2) * abs(s3 - s4) << endl;    
    return 0;
}


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

int main() {
	string a,b;
	cin >> a >> b;
	if(a.size()>b.size()){
		cout <<"GREATER";
	}else if(b.size()>a.size()){
		cout << "LESS";
	}else{
		for(int i=0; i<a.size(); i++){
			if(a[i]>b[i]){
				cout << "GREATER";return 0;
			}else if(a[i]<b[i]){
				cout << "LESS";return 0;
			}
		}
		cout << "EQUAL";
	}
	
}

Measured memory_bytes: 256
import heapq
import math

N, M = map(int, input().split())
A = list(map(int, input().split()))
for i in range(len(A)):
  A[i] = A[i] * -1

heapq.heapify(A)

for _ in range(M):
  el = heapq.heappop(A)
  heapq.heappush(A, math.ceil(el/2))

print(sum(A) * -1)


Measured memory_bytes: 14532
#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>
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)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


    using namespace std;
 
    int main(){
      int n;
      cin >> n;
      cout << 800*n-200*(n/15) << endl;
      return 0;}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

string S,T;

signed main(){
    cin>>S>>T;

    int s[26],t[26];
    memset(s,-1,sizeof(s));
    memset(t,-1,sizeof(t));
    rep(i,S.size()){
        int a=S[i]-'a';
        int b=T[i]-'a';
        if(s[a]!=t[b]){
            cout<<"No"<<endl;
            return 0;
        }
        s[a]=i;
        t[b]=i;
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 776
def calc(n)
  (1...n).reduce([1, 1]){ |b, i| [b[0] * i + b[1], b[1] * i] }
end
while true
  n, k, m, r = gets.split.map(&:to_i)
  break if n == 0
  if m == 0 then x, y = 1, n
  else
    x, y = calc(n)
    y *= n
    g = x.gcd y
    x /= g; y /= g
  end 
  x, mod = x.divmod y
  print x, '.'
  x = mod * 10
  r.times.reduce(x){ |t, _| t, mod = t.divmod y; print t; mod * 10 }
  puts
end

Measured memory_bytes: 90876
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define F first
#define S second
#define vi vector
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i=a;i<=b;i++)
#define FORR(i,a,b) for(int i=a;i>=b;i--)
#define mod 1000000007
#define pb push_back
#define ll long long 
#define db double
#define all(v) v.begin(),v.end()

using namespace std;

/*

ll expo(ll n){
    ll t;
    if(n==0)return 1;
    else if(n==1) return 2;
    t=expo(n/2);
    if(n%2){
        return t*t*2;
    }
    else return t*t;
}

//ffrom geek for geek
ll exponentMod(ll A, ll B, ll C)  
{  
    if (A == 0)  
        return 0;  
    if (B == 0)  
        return 1;  
    ll y;  
    if (B % 2 == 0) {  
        y = exponentMod(A, B / 2, C);  
        y = (y * y) % C;  
    }  
    else {  
        y = A % C;  
        y = (y * exponentMod(A, B - 1, C) % C) % C;  
    }  
  
    return (ll)((y + C) % C);  
}

*/
/*
class dsu{
public:    
vi<ll> v;


void init(ll n){
    v.assign(n+1,-1);
}

 
ll dsufind(ll x){
    if(v[x]<0){
        return x;
    }
    v[x]=dsufind(v[x]);
    return v[x];
}
 
void dsujoin(ll x,ll y){
    x=dsufind(x);
    y=dsufind(y);
    
    if(x==y)
    return;
    if(v[x]>v[y])swap(x,y);
    v[y]+=v[x];
    v[x]=y;
}

};
*/


ll h,w,k;
char s[10][10];
ll visx[10]={0},visy[10]={0},ans=0;




void update(){
    ll now=0;

    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(visx[i]||visy[j])continue;
            if(s[i][j]=='#')
            now++;
        }
    }
    if(now==k)
    ans++;
}


void dfs2(ll x,ll ok){
    visy[x]=ok;
    if(x==w){update();return;}
    else if(x+1<=w){dfs2(x+1,0);
    dfs2(x+1,1);
    return;
    }   
}



void dfs1(ll x,ll ok){
    visx[x]=ok;
    if(x==h){dfs2(0,0);return;}
    else if(x+1<=h){
        dfs1(x+1,0);
        dfs1(x+1,1);
        return;
    }
}


int main(){
    //IOS;
    ll t;
    t=1;
    //cin>>t;
    while(t--){
        cin>>h>>w>>k;
        for(int i=1;i<=h;i++){
            for(int j=1;j<=w;j++){
                cin>>s[i][j];
            }
        }
        dfs1(0,0);
        cout<<ans;
    }
    
    return 0;
} 

Measured memory_bytes: 3616
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>



using ll = long long;


using namespace std;
int gcd(int a, int b) {
	if (a < b) {
		int t = a;
		a = b;
		b = t;
	}
	
	while (b != 0) {
		int t = b;
		b = a % b;
		a = t;
	}
	return a;
}

int factorial(ll n) {
	if (n > 0) {
		return n * factorial(n - 1);
	}
	else
		return 1;
}
int main()
{/*13日目*/
	int a, b;
	cin >> a >> b;
	if (b % 2 != 0) {
		cout << "No";
		return 0;
	}
	if (2 * a <= b and b <= 4 * a)
		cout << "Yes";
	else
		cout << "No";



}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define lowbit(a) ((a)&(-(a)))
using namespace std;

void file(bool opt)
{
	if (opt&&fopen("in.txt", "r"))
	{
		freopen("in.txt", "r", stdin);
		//freopen("out.txt", "w", stdout);
	}
}

const long long mod = 1e9 + 7;
long long dp[100000 + 5];
bool check[100000 + 5];
int main()
{
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= m; i++)
	{
		int x;
		scanf("%d", &x);
		check[x] = 1;
	}
	dp[0] = 1;
	for (int i = 1; i <= n; i++)
	{
		if (i - 1 >= 0 && !check[i - 1])dp[i] = (dp[i] + dp[i - 1]) % mod;
		if (i - 2 >= 0 && !check[i - 2])dp[i] = (dp[i] + dp[i - 2]) % mod;
	}
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 1152
import itertools

while(1):
 n = int(input())
 k = int(input())
 if((n == 0)and(k == 0)): break

 num = []
 for i in range(n): num.append(input())
 #print('num :::',num)
 
 A = []
 for i in range(n): A.append(i)
 #print('A :::',A)

 num_list = []
 Comb = list(itertools.permutations(A,k))
 #print('Comb :::',len(Comb))
 
 for i in range(len(Comb)):
  tmp = list(Comb[i])
  tmp_num = ''
  for j in range(len(tmp)):
   tmp_num += num[tmp[j]]
  tmp_num = int(tmp_num)
  num_list.append(tmp_num)

 ans = len(list(set(num_list))) 
 print(ans)
 #print('aaaa')


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

using namespace std;

int main() {

	long long rez = 0;
	vector<int> freq(2019);	
	string s;
	cin >> s;
	freq[0] = 1;
	int md = 0, p = 1;
	for (int i = (int)s.size() - 1; i >= 0; i--) {
		md = (md + p * (s[i] - '0'))	% 2019;
		rez += freq[md];
		freq[md]++;
		p = p * 10 % 2019;
	}
	cout << rez << "\n";
}


Measured memory_bytes: 3740
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define REP rep
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
const ll MOD=1e9+7;

#define rall(X) (X).rbegin(),(X).rend()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}

int N;

using BS = bitset<100010>;
vector<LL> as;

using Mat = vector<BS>;

bool Gauss(Mat &mat) {
  int m = N+1;
  int n = mat.size();
  int cur = 0;
  rep(j, m) {
    bool found = false;
    reps(i, cur, n) {
      if (!mat[i][j]) continue;
      
      // swap
      rep(k, m) {
        char tmp = mat[cur][k];
        mat[cur][k] = mat[i][k];
        mat[i][k] = tmp;
      }
      found = true;
      break;
    }

    if (!found) continue;

    rep(i, n) {
      if (i == cur) continue;
      if (!mat[i][j]) continue;
      mat[i] ^= mat[cur];
    }
    cur++;
  }

  //cout << "res: \n";
  //rep(i, n) {
  //  rep(j, m) {
  //    cout << (int)mat[i][j] << " ";
  //  }cout << endl;
  //}cout << endl;

  rep(i, n) {
    int cnt = 0;
    rep(j, m-1) {
      cnt += mat[i][j];
    }
    if (cnt == 0 && mat[i][m-1]) return false;
  }
  return true;
}

signed main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);

  cin >> N;
  as.resize(N);
  rep(i, N) {
    cin >> as[i];
  }

  LL ans = 0;
  Mat m;
  rrep(i, 61) {
    char cond = 0;
    rep(j, N) {
      cond ^= (as[j] >> i & 1);
    }

    if (cond == 1) {
      //cout << i << ": cond is 1, +" << (1LL << i) << endl;
      ans += 1LL << i;
      continue;
    }

    BS row;
    rep(j, N) {
      row[j] = (as[j] >> i & 1);
    }
    row[N] = 1;
    m.eb(row);
    Mat tmp(m);
    if (Gauss(tmp)) {
      //cout << i << ": cond is 0, and satis +" << (1LL << (i+1)) << endl;
      ans += 1LL << (i+1);
      continue;
    }
    m.pop_back();
  }
  cout << ans << endl;
}


Measured memory_bytes: 2928
#include<bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define zero(v) memset(v,0,sizeof(v))
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
const double EPS=1e-10;
typedef pair<int,int>P;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
int main(){
	int n;
	cin>>n;
	int t=n%10;
	if(t==2||t==4||t==5||t==7||t==9){
		cout<<"hon"<<endl;
	}
	else if(t==0||t==1||t==6||t==8){
		cout<<"pon"<<endl;
	}
	else{
		cout<<"bon"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3620
import java.util.*;
import java.lang.*;

class Mod{
    static final long MOD = 1000_000_007;
    static final long[] fact = makeFactorialArray(1000000);
    static final long[] factInv = makeInversedArray(fact);

    public static long add(long a, long b){
        long tmp = (a+b)%MOD;
        return tmp>=0 ? tmp : tmp+MOD;
    }
    public static long adds(long... ar){
        long ans=0;
        for(long x:ar) ans = Mod.add(ans, x);
        return ans;
    }
    public static long sub(long a, long b){
        return add(a,-b);
    }
    public static long mult(long a, long b){
        long tmp = (a*b)%MOD;
        return tmp>=0 ? tmp : tmp+MOD;
    }
    public static long mults(long... ar){
        long ans=1;
        for(long x:ar) ans = Mod.mult(ans, x);
        return ans;
    }
    public static long power(long a, long x){ //calculate a^x
        if(x<0)return 0;
        if(x==0)return 1;
        if(x%2==0) {
            long half = power(a,x/2);
            return mult(half,half);
        }
        return (a*power(a,x-1)) % MOD;
    }
    public static long inverse(long a){
        return power(a,MOD-2);
    }
    public static long div(long a, long b){
        return mult(a, inverse(b));
    }
    public static long[] makeFactorialArray(int size){
        long[] array = new long[size];
        array[0]=1;
        for(int i=1;i<size;i++){
            array[i]=mult(array[i-1],i);
        }
        return array;
    }
    public static long[] makeInversedArray(long[] original){
        long[] array = new long[original.length];
        for(int i=0;i<original.length;i++){
            array[i] = inverse(original[i]);
        }
        return array;
    }
    public static long combination(int n, int r){
        if(n<0 || r<0 || n<r) return 0;
        return mult(fact[n], mult(factInv[r],factInv[n-r]));
    }

}
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int dog = sc.nextInt();
        int monkey = sc.nextInt();

        if(dog==monkey) System.out.println(Mod.mults(Mod.fact[dog], Mod.fact[monkey], 2));
        else if(Math.abs(dog-monkey)==1) System.out.println(Mod.mults(Mod.fact[dog], Mod.fact[monkey]));
        else System.out.println(0);
    }
}


Measured memory_bytes: 38096
fun main(args: Array<String>) = ABC167A.main()

object ABC167A {
    fun log(message: Any?) {
        println(message)// TODO: ←消す
    }

    fun main() {
        val S = readString()
        val T = readString()
        val ans = (S == T.take(S.length) && S.length + 1 == T.length)
        println(ans.yesOrNo())
    }


    /*####################################################################################*/

    fun readString() = readLine()!!
    fun readStrings() = readLine()!!.split(" ")
    fun readInt() = readLine()!!.toInt()
    fun readInts() = readLine()!!.split(" ").map { it.toInt() }
    fun readLong() = readLine()!!.toLong()
    fun readLongs() = readLine()!!.split(" ").map { it.toLong() }
    fun readMatrixRows(height: Int) = (1..height).map { readLine()!!.toList() }

    fun Boolean.yesOrNo() = if (this) "Yes" else "No"
    fun Double.toNaturalExpr() = println("%f".format(this))
}

Measured memory_bytes: 35912
#include<bits/stdc++.h>
#define god dimasi5eks
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front

// #define fisier 1

using namespace std;

typedef long long ll;

const int mod = 998244353;
const double dancila = 3.14159265359; // PI 
const double eps = 1e-9;

int n;

vector<pair<int, int> >ar[2000002];
int main()
{

    #ifdef fisier
        ifstream cin("input.in");
        ofstream cout("output.out");
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	cin >> n;
	int dif = 0;
	int dif2 = 0;
	for(int i = 1; i <= n; ++i)
	{
		string s;
		cin >> s;
		deque<char> d;
		for(int j = 0; j < s.size(); ++j)
		{
			if(!d.empty() && s[j] == ')' && d.back() == '(')
				d.pop_back();
			else
				d.pb(s[j]);
		}
		if(!d.empty() && d[0] == '(')
			dif += d.size();
		else
		{
			int dsc = 0;
			int cl = 0;
			for(int j = 0; j < d.size(); ++j)
				if(d[j] == '(')
					dsc++;
				else
					cl++;
			if(!dsc)
				dif2 += cl;
			else
			{
				ar[1000000 + dsc - cl].pb({cl, dsc});
			}
		}
	}
	multiset<pair<int, int> >prd;
	for(int i = 1000001; i <= 2000000; ++i)
		for(auto pr : ar[i])
			prd.insert(pr);
	while(!prd.empty())
	{
		pair<int, int> xx = *prd.begin();
		if(dif >= xx.fi)
			dif = dif - xx.fi + xx.se, prd.erase(prd.lower_bound(xx));
		else
		{
			cout << "No";
			return 0;
		}
	}
	for(int i = 1000000; i >= 0; --i)
	{
		for(auto pr : ar[i])
		{
			if(dif < pr.fi)
			{
				cout << "No";
				return 0;
			}
			dif = dif - pr.fi + pr.se;
		}
	}
	dif -= dif2;
	if(dif == 0)
		cout << "Yes";
	else
		cout << "No";
    return 0;
}


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

int main() {
    int N, x;
    long long K;
    cin >> N >> K;
    int A[N], B[N];
    for (int i = 0; i < N; i++) {
        cin >> x;
        A[i] = x-1;
        B[i] = -1;
    }

    int p = 0;
    int s = 0;
    B[0] = 0;
    while (true) {
        p = A[p];
        s++;
        //cout << '(' << s << ',' << p << ')' << endl;
        if (s == K) {
            cout << p+1 << endl;
            return 0;
        }
        if (B[p] >= 0) {
            break;
        } else {
            B[p] = s;
        }
    }

    int l = s - B[p];
    K = (K - s) % l;
    //cout << l << ' ' << K << endl;
    s = 0;
    while (s < K) {
        p = A[p];
        s++;
    }
    cout << p+1 << endl;
    return 0;
}


Measured memory_bytes: 5140
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

const int N = 2019;

int main() {
    ll l, r;
    cin >> l >> r;

    if(r-l >= N) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = N;
    for(ll i = l; i < r; i++) {
        for(ll j = i+1; j <= r; j++) {
            ll t = (i*j)%N;
            ans = min(ans, t);
        }
    }

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

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

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

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

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

const double pi = 3.141592653589793;
// -------------------------------------------------------
ll A;
long double B;

int main() {
  cin >> A >> B;
  B *= 100.0;
  ll b = B + 0.001;
  ll ans = A * b / 100LL;
  cout << ans << endl;
}


Measured memory_bytes: 3752
#include<stdio.h>
int main(void){
    int a,b,op,c;
    while(1){
        scanf("%d %c %d",&a,&op,&b);
        if( op =='+'){
            c=a+b;
        } else if(op=='-'){
            c=a-b;
        } else if(op=='*'){
            c=a*b;
        } else if(op=='/'){
            c=a/b;
        }
        if(op=='?')break;
        printf("%d\n",c);
    }
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

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

    cin >> n;
    
    if(n % 2){
        //余りあり、奇数。
        cout << n * 2 << endl;
    }else{
        cout << n << endl;
    }
    return 0;
}

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

int main() {

  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);

  int X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;

  vector<int> a(A), b(B), c(C);
  for (int i = 0; i < A; ++i)
    cin >> a[i];

  for (int i = 0; i < B; ++i)
    cin >> b[i];

  for (int i = 0; i < C; ++i)
    cin >> c[i];

  multiset<int> m;
  sort(a.begin(), a.end(), greater<int>());
  sort(b.begin(), b.end(), greater<int>());
  sort(c.begin(), c.end(), greater<int>());

  long long ans = 0;
  for (int i = 0; i < X; ++i) {
    m.insert(a[i]);
    ans += a[i];
  }

  for (int i = 0; i < Y; ++i) {
    m.insert(b[i]);
    ans += b[i];
  }

  for (int i = 0; i < C; ++i) {
    if (c[i] > *m.begin()) {
      ans -= *m.begin();
      m.erase(m.begin());
      ans += c[i];
      m.insert(c[i]);   
    }
  }

  cout << ans << '\n';
}


Measured memory_bytes: 9856
import scala.io.StdIn
object Main extends App {
  val n = StdIn.readInt
  val as = (1 to n).map(i => StdIn.readLong).sorted.toArray
  def sum(begin: Int, end: Int) = (begin to end).map(i => as(i)).sum

  val m = n / 2
  println(if (n % 2 == 1) {
    (sum(m + 2, n - 1) * 2 + as(m + 1)) - (sum(0, m - 2) * 2 + as(m - 1)) +
    Math.max(as(m + 1) - as(m), as(m) - as(m - 1))
  } else {
    (sum(m + 1, n - 1) * 2 + as(m)) - (sum(0, m - 2) * 2 + as(m - 1))
  })
}

Measured memory_bytes: 47176
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


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

  stack<char> q;
  rep(i, s.size()){
    if (s[i] == 'B'){
      if (q.empty()) continue;
      q.pop();
    }else{
      q.push(s[i]);
    }
  }

  string ans = "";
  while(!q.empty()) {
    ans += q.top(); q.pop();
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fo(i, u, v) for(int i = u; i <= v; ++i)
#define fob(i, u, v) for(int i = u; i >= v; --i)
#define fi first
#define se second
#define si size()
#define pb push_back

using namespace std;
typedef double db;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
const ll N = 1e6+7;
const ll inf = ll(1e18);
const ll  MOD = 1e9+7;
const string name = "template";
template <class T> int getbit(T x, int y) {return x >> (y-1) & 1;}
template <class T> T sqr(T x) {return x*x;}
template <class T> void read_int(T &rs) {
    char c;
    int sign = 1;
    for(c = getchar(); c < '0' || c > '9'; c = getchar())
        if(c == '-') sign *= -1;
    rs = (c - '0');
    for(c = getchar(); c >= '0' && c <= '9'; c = getchar())
        rs = rs*10 + (c - '0');
    rs *= sign;
}

ll n, a[N], f[N], b[N], trace[N], maxx = -inf, p, cnt;
vector <ll> way;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen((name + ".inp").c_str(), "r", stdin);
    //freopen((name + ".out").c_str(), "w", stdout);
    cin >> n;
    fo(i, 1, n) cin >> a[i];
    fo(i, 1, n) {
        f[i] = a[i];
        for(int j = i - 2; j >= 0; j -= 2)
        if(f[j] + a[i] > f[i]) {
            f[i] = f[j] + a[i];
            trace[i] = j;
        }
        if(f[i] > maxx) {maxx = f[i]; p = i;}
    }
    cout << maxx << '\n';

    do{
        b[p] = 1;
        p = trace[p];
    } while(p > 0);
    int i = 1;
    while(b[i] == 0 && i <= n) {way.pb(1); cnt++; i++;}
    i++;
    while(i <= n) {
        int j = i + 1;
        while(b[j] == 0 && j <= n) j++;
        fo(ii, 1, (j - i)/2) way.pb(i + 1 - cnt);
        way.pb(i - cnt);
        cnt += j - i + 1;
        //cerr << i << " " <<j << endl;
        i = j + 1;
    }

    cout << way.si << '\n';
    fo(i, 0, way.si-1) cout << way[i] << '\n';
    return 0;
}


Measured memory_bytes: 6400
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 1LL << 61;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222


string mass[1111];
ll dist[1111][1111];
bool visited[1111][1111];

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



  ll h, w;
  cin >> h >> w;
  rep(i, w + 2) s.pb('x');
  mass[0] = s;
  mass[w + 1] = s;
  rep(i, h) {
    cin >> s;
    mass[i + 1] = "x" + s + "x";
  }
  deque<pair<ll, pll>> dq;
  FOR(i, 1, h + 1) FOR(j, 1, w + 1) {
    if (mass[i][j] == '#') {
      dq.push_front(make_pair(0, pll(i, j)));
      visited[i][j] = true;
    }
  }
  while (!dq.empty()) {
    pair<ll, pll> p = dq.front();
    dq.pop_front();
    ll d = p.first;
    ll y = p.second.first;
    ll x = p.second.second;
    FOR(k, 1, 5) {
      if (mass[y + dy[k]][x + dx[k]] != '.') continue;
      if (visited[y + dy[k]][x + dx[k]]) continue;
      dist[y + dy[k]][x + dx[k]] = d + 1;
      visited[y + dy[k]][x + dx[k]] = true;
      dq.push_back(make_pair(d + 1, pll(y + dy[k], x + dx[k])));
    }
  }
  FOR(i, 1, h + 1) FOR(j, 1, w + 1) ma = max(ma, dist[i][j]);
  cout << ma << endl;


  return 0;
}

Measured memory_bytes: 27580
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int x,a,b;
    cin>>x>>a>>b;
    if(a>=b)cout<<"delicious"<<endl;
    else
    {
        if(x>=abs(a-b))cout<<"safe"<<endl;
        else cout<<"dangerous"<<endl;
    }

}


Measured memory_bytes: 256
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000007
#define ull unsigned long long
#define ll long long
template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}


int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	string s;
	cin >> s;
	int n = s.length();
	for(int i=0;i<n-1;++i) {
		if(s[i]=='A' && s[i+1]=='C') {cout << "Yes" << endl; return 0;}
	}
	cout << "No" << endl;
}

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

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;

#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))

int F()
{
	char ch;
	int x, a;
	while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
	if (ch == '-') ch = getchar(), a = -1;
	else a = 1;
	x = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9')
		x = (x << 1) + (x << 3) + ch - '0';
	return a * x;
}

const int N = 2e5 + 10;

char str[N], stk[N];

int n, tp;

int main()
{
	scanf("%s", str + 1);
	n = strlen(str + 1);
	for (int i = 1; i <= n; ++i)
	{
		if (tp > 0 && stk[tp] == 'S' && str[i] == 'T') --tp;
		else stk[++tp] = str[i];
	}
	printf("%d\n", tp);
	return 0;
}



Measured memory_bytes: 640
N = 100005
require 'prime'
hash = Hash.new{false}
for i in 1..N
    hash[i] = true if Prime.prime?(i)
end
cum = Array.new(N + 1, 0)
cum[0] = 0
N.times do |i|
    cum[i + 1] += cum[i]
    cum[i + 1] += 1 if (i + 1).odd? && hash[i + 1] && hash[(i + 2) / 2] 
end
Q = gets.to_i
Q.times do |i|
    a, b = gets.split.map(&:to_i)
    puts cum[b] - cum[a - 1]
end 


Measured memory_bytes: 4092
#include <iostream>
#include <string>
using namespace std;
int main() {
    string s;
    while(1) {
        getline(cin, s);
        if (s == "0") break;
        int sum = 0;
        for (int i = 0; i < s.size(); i++) {
            sum += s[i] - '0';
        }
        cout << sum << endl;
    }
    return 0;
}


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

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

  for (int i = 1; i <= n; i++) {
    ll ans = 0;
    for (int x = 1; x <= (int)sqrt(i)+1; x++) {
      for (int y = x; y <= (int)sqrt(i)+1; y++) {
        for (int z = y; z <= (int)sqrt(i)+1; z++) {
          if (x*x+y*y+z*z+x*y+y*z+z*x == i) {
            if (x == y && y == z) {
              ans++;
            } else if (x != y && y != z && z != x){
              ans += 6;
            } else {
              ans += 3;
            }
          }
        }
      }
    }
    cout << ans << endl;
  } 
  return 0;
}

Measured memory_bytes: 3520
#include <bits/stdc++.h>
#define ll long long
#define int long long
#define MOD 1000000007
#define endl "\n"
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pii>
#define vvi vector<vi>
#define endl "\n"
using namespace std;
void solve1();
void solve()
{
    int t;cin>>t;
    while(t--)
    {
        solve1();
    }
}
signed main()
{
    solve1();
}
void solve1()
{
    int n;cin>>n;
    int arr[n];int ans=0;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];ans^=arr[i];
    }
    for(int i=0;i<n;i++)
    {
        cout<<(ans^arr[i])<<" ";
    }cout<<endl;
}


Measured memory_bytes: 4996