akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define ss second
#define ff first
#define mp make_pair
#define ll long long int
using namespace std;
 
vector<ll> vec;
vector<pair<ll,ll> > vp;
ll mini;
 
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

map<ll,ll> has,mark;
set<ll> st;
 
ll ar[5000002],br[5123456];

const ll MOD = 1e9 + 7;
 
 
 
int main() 
{
	ll c,i,p,q,d,k,len,y,j,a,b,t,ans,flag,n,m,g=0,res=0,sum=0,e,f,r,minm=99999999999,maxm=-999999999999,x,hr,secmaxm=-999999999999,z;
	c=0;
//	freopen("output.out","w",stdout);
	string str,ptr,dtr;
	char ch,prev;
	
	set<ll>::iterator it;
	
	cin>>a>>b;
	
	if((a*b)%2==0)
	cout<<"Even";
	else
	cout<<"Odd";
	
	return 0;
}   

Measured memory_bytes: 764
#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;

int main () {
  int s;
  cin >> s;
  int d1, d2, d3, d4;
  d1=s/1000;
  d2=s/100-(d1*10);
  d3=s/10-d1*100-d2*10;
  d4=s%10;
  if ((d1==0&&d2>=1)||(d1==1&&d2<=2)){
    if ((d3==0&&d4>=1)||(d3==1&&d4<=2))
      cout << "AMBIGUOUS";
    else
      cout << "MMYY";
  }
  else if ((d3==0&&d4>=1)||(d3==1&&d4<=2))
    cout << "YYMM";
  else
    cout << "NA";

  return 0;
}


Measured memory_bytes: 256
import Control.Applicative
import Data.List



check :: Int -> Int -> [String]
check h w = [[(if (x+y)`mod`2==0 then '#' else '.') | x<-[1..w] ] | y<-[1..h] ]

main = do
{
    l <- map (map (read::String->Int) . words) . init . lines <$> getContents;
    let{
        sqs = [ check (x!!0) (x!!1)  | x<-l ];
    };
    mapM_ (mapM_ putStrLn) $ map (++[""]) sqs;
}

Measured memory_bytes: 5060
#include <bits/stdc++.h>
using namespace std;
#define ft              first
#define sd              second
#define ll  		long long
#define pb              push_back
#define mkp           make_pair
#define pll             pair<ll,ll>
#define vll             vector<int>
#define mll             map<ll,ll>
#define pqg             priority_queue<ll>
#define pqs             priority_queue<ll,vll,greater<ll>>
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod          1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define MAXN   10000001
void online_judge()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
}

void ISO()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}


int main() {

	ISO();
	//online_judge();

	int n;
	cin >> n;
	int a[n];
	ll ans = 0;
	for(int i=0;i<n;++i)
	{
		cin >> a[i];
	}
	int temp = a[0];
	for(int i=1;i<n;++i)
	{
		if(a[i] < temp)
		{
			ans += abs(a[i] - temp);
		}
		else
		{
			temp = a[i];
		}
	}
	cout << ans <<"\n";


	//cerr << "Time elapsed: " << clock() / 1000 << " ms" << endl;
	return 0;
}

Measured memory_bytes: 4396
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def MI(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

from itertools import permutations

N,M,R = LI()
r = LI()
A,B,C = MI(M,3)

def WF(E,n):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                E[i][j] = min(E[i][j],E[i][k]+E[k][j])
    return E

E = [[float('inf')]*N for _ in range(N)]
for i in range(N):
    E[i][i] = 0         #自分との距離は0にしておく
for i in range(M):
    E[A[i]-1][B[i]-1] = C[i]
    E[B[i]-1][A[i]-1] = C[i]     #無向枝の場合両方格納

E2 = WF(E,N) #全ての点の組み合わせの距離を2次元配列で返す

X = list(permutations(r))
ans = float('inf')

for x in X:
    now = 0
    for i in range(1,len(x)):
        now += E2[x[i-1]-1][x[i]-1]
    if now < ans:
        ans = now

print(ans)

Measured memory_bytes: 62940
#include <bits/stdc++.h>
using namespace std;
const int M=1e5+5;
int a[M],cnt;
int main()
{
    int n;scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        int x;scanf("%d",&x);
        a[x]++;
    }
    int cost=0;
    for(int i=1;i<M;i++)if(a[i]>=2)
    {
        if(a[i]%2==0)
        {
            cost+=a[i]-2;
            cnt++;
        }
        else cost+=a[i]-1;

    }
    cost+=(cnt/2)*2;
    if(cnt%2==1)cost+=2;
    printf("%d\n",n-cost);
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL N = 200010;
struct Edge
{
    LL next;
    LL dis;
    LL to;
}edge[N*2];
LL head[N*2];
LL res[N*2];
LL r[N*2];
LL tot;
LL n,m;
bool vis[N*2];
inline void add(LL from,LL to)
{
    edge[++tot].next = head[from];
    edge[tot].to = to;
    head[from] = tot;
}
void init()
{
    memset(head,-1,sizeof(head));
}
void bfs()
{
   queue<LL> Q;
   Q.push(1);
   while(Q.size())
   {
       LL x = Q.front();
       vis[x] = 1;
       Q.pop();
       for(LL i = head[x];~i;i = edge[i].next)
       {
           LL y = edge[i].to;
         if(!vis[y]) {
           res[y] += res[x];
           Q.push(y);
       }
       }
   }

}
int main()
{
  //freopen("input.txt","r",stdin);
   init();
   scanf("%lld%lld",&n,&m);
   LL f,t;
   for(LL i = 1;i<=n-1;++i)
   {
       scanf("%lld%lld",&f,&t);
       add(f,t);
       add(t,f);
   }
   for(LL i = 1;i<=m;++i)
   {
       scanf("%lld%lld",&f,&t);
       res[f] += t;
   }
   bfs();
   for(LL i = 1;i<=n;++i)
    printf("%lld ",res[i]);
}


Measured memory_bytes: 19712
using System;
using System.Linq;

namespace C___Stones
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();
            var S_rev = string.Join("", S.Reverse());

            int[] w_arr = new int[N + 1], b_arr = new int[N + 1];
            int cost = 0, min = int.MaxValue;

            for (int i = 0; i <= N; i++)
            {
                if (i == 0)
                {
                    w_arr[i] = 0;
                    b_arr[i] = 0;
                    continue;
                }

                w_arr[i] = S[i - 1] == '#' ? w_arr[i - 1] + 1 : w_arr[i - 1];
                b_arr[i] = S_rev[i - 1] == '.' ? b_arr[i - 1] + 1 : b_arr[i - 1];
            }

            for (int i = 0; i <= N; i++)
            {
                cost = w_arr[i] + b_arr[N - i];
                min = Math.Min(min, cost);
            }

            Console.WriteLine(min);
        }
    }
}

Measured memory_bytes: 21340
function main(arg) {
	arg = arg.trim().split('\n');
  	var n = Number(arg[0]),  
        s = arg[1],
        c = Math.round(n/2);
  var out = s.substr(0, c),
      out = out+out === s ? 'Yes': 'No'
  console.log(out)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main(void) {
  ll N, M, L;
  cin >> N >> M >> L;
  vector<ll> K(N), S(M);
  REP(i, 0, N) cin >> K[i], K[i]--;
  REP(i, 0, M) cin >> S[i];

  sort(K.begin(), K.end());
  vector<ll> sum(M + 1);
  REP(i, 0, M) sum[i + 1] = sum[i] + S[i];

#define cost(p, q) ((sum[(q) + 1] - sum[(p)]) / L)
  const ll INF = 1LL << 60;
  vector<vector<ll>> dp(N, vector<ll>(N, INF));
  dp[0][0] = 0;
  REP(i, 0, N - 1) REP(j, 0, N - 1) {
    ll k = max(i, j) + 1;
    if (k == N - 1) {
      dp[k][k] = min(dp[k][k], dp[i][j] + cost(K[i], K[k]) + cost(K[j], K[k]));
    } else {
      dp[k][j] = min(dp[k][j], dp[i][j] + cost(K[i], K[k]));
      dp[i][k] = min(dp[i][k], dp[i][j] + cost(K[j], K[k]));
    }
  }
  cout << dp[N - 1][N - 1] << endl;
}


Measured memory_bytes: 35872
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(s...)  fprintf(stderr, s)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }

int N, A, B;
char S[100111];

int main() {
    scanf("%d%d%d%s", &N, &A, &B, S);

    int cA = 0, cB = 0;
    REP (i, N) {
	bool yes;

	if (S[i] == 'a') {
	    if (cA + cB < A + B) {
		yes = true;
		cA++;
	    } else {
		yes = false;
	    }
	} else if (S[i] == 'b') {
	    if (cA + cB < A + B && cB < B) {
		yes = true;
		cB++;
	    } else {
		yes = false;
	    }
	} else {
	    yes = false;
	}

	puts(yes? "Yes": "No");
    }


    return 0;
}



Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
using namespace std;
 
int main() {
  int n;
  unsigned long long a[100000];
  unsigned long long dot[100001]; 
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a[i] ;
  }

  dot[0] = 1;
  unsigned long long d;
  d = sqrt(1000000000000000000);
  
  sort(a,a+n);
  if(a[0] == 0){
        cout << "0" << endl;
        return 0;  
  }
  
  sort(a,a+n,greater<int>());
  if(a[1] > d){
        cout << "-1" << endl;
        return 0;    
  }

  for(int i = 0; i < n; i++){
    dot[i+1] = (dot[i] * a[i]) ;
    if(dot[i+1] > 1000000000000000000){
        cout << "-1" << endl;
        return 0;
    }
  }
 
  cout << dot[n] << endl;

}


Measured memory_bytes: 5164
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

int main(){
  string a,b,c;
  cin >> a >> b >> c;
  int size_1, size_2 ;
  size_1 = a.size()-1; 
  size_2 = b.size()-1;
  if(a.at(size_1) == b.at(0) && b.at(size_2) == c.at(0)){
    cout << "YES";
  }else{
    cout << "NO";
  }
  cout << endl; 
} 


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

class UnionFind {
private:
	vector<long long> par;
public:
	UnionFind(int N) { par = vector<long long>(N, -1LL); }
	int find(int x);
	long long size(int x);
	void unite(int x, int y);
	bool same(int x, int y);
};
//----UnionFind-------------------------------
int UnionFind::find(int x) {
	if (par[x] < 0) return x;
	else return par[x] = find(par[x]);
}

long long UnionFind::size(int x) {
	return -par[find(x)];
}

void UnionFind::unite(int x, int y) {
	//既に同じ集合に属しているならば繋げない
	if (same(x,y)) return;

	x = find(x);
	y = find(y);

	//大きい方に小さい方をくっ付ける
	if (size(x) < size(y)) swap(x, y);
	par[x] += par[y];
	par[y] = x;
}

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

int main() {
	long long n,m;
	cin >> n >> m;
	long long ans[m+1];
	long long A[m],B[m];
	UnionFind uf(n);

	for (int i = 0;i < m;i++) {
		cin >> A[i] >> B[i];
	}

	ans[m] = n * (n - 1) / 2;
	for (int i = m - 1;i >= 0;i--) {
		if (!uf.same(A[i]-1,B[i]-1)) {
			ans[i] = ans[i+1] - uf.size(A[i]-1) * uf.size(B[i]-1);
		} else {
			ans[i] = ans[i+1];
		}
		uf.unite(A[i]-1,B[i]-1);
	}

	for(int i = 1;i < m + 1;i++) {
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
int main(){
    long long h;
    int n;
    cin  >> h >> n;
    long long sum = 0;
    long long t;
    rep(i,n) cin >>t,sum+=t;
    if(sum>=h) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int n, p, a[50], c[2];
int main(void){
  cin >> n >> p;
  for(int i=0;i<n;i++){
    cin >> a[i];
    c[a[i]%2]++;    
  }
  long long int ans = 1LL << c[0], ans2;
  if (c[1]>0){
    ans2 = 1LL << (c[1]-1);
  }else{
    ans2 = 1 - p;
  }
  ans *= ans2;
  cout << ans << endl;
  return 0;
}
  
  
  

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

const int MAX = 200;
int stack[MAX];
int top = -1;

bool push(int s[], int c)
{
	if (top < MAX)
	{
		s[++top] = c;
		return true;
	}
	else 
		return false;
}

int main()
{
	string str;
	while (cin >> str)
	{
		if (str != "+" && str != "-" && str != "*")
			push(stack, stoi(str));
		else if (str == "+")
		{
			int a, b, c;
			a = stack[top--];
			b = stack[top--];
			c = b + a;
			push(stack, c);
		}
		else if (str == "*")
		{
			int a, b, c;
			a = stack[top--];
			b = stack[top--];
			c = b * a;
			push(stack, c);
		}
		else {
			int a, b, c;
			a = stack[top--];
			b = stack[top--];
			c = b - a;
			push(stack, c);
		}
	}
	cout << stack[top] << endl;
	return 0;
}




Measured memory_bytes: 3172
n,d = map(int,input().split())
a = []
for i in range(n):
    x = list(map(int,input().split()))
    a.append(x)

c = 0  #count_all

for j in range(n-1):
    for k in range(j+1,n):
        distance = 0
        for l in range(d):
            distance += (abs(a[j][l]-a[k][l]))**2
        distance = distance**0.5

        if distance.is_integer() == True:
            c += 1

print(c)

Measured memory_bytes: 3064
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix

# slist = "abcdefghijklmnopqrstuvwxyz"
A,B = map(int,input().split())

ans = 0
for i in range(A,B+1):
    if str(i) == str(i)[::-1]:
        ans +=1

print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 2940
from functools import reduce

N, X = map(int, input().split())

def _calc(a,b):
    while b:
        a, b = b, a % b
    return a

def calc(n_list):
    return reduce(_calc, n_list)

c = list(map(int, input().split()))
c = [ abs(x-X) for x in c ]

print(calc(c))

Measured memory_bytes: 14596
#include<bits/stdc++.h>
#define int			long long
#define ll 			long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define dep(i,a,b)	for(int i=a;i>=b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005

void solve()
{
	string s;
	cin>>s;
	ll n = s.size();
	ll sm=0;
	for(int i=0;i<n;i++){
		sm+=s[i]-'0';
	}
	if(sm%9==0){
		cout<<"Yes"<<endl;
	}
	else cout<<"No"<<endl;
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define rt return 0
#define endln "\n"
#define all(v) v.begin(), v.end()
#define for1(i, a, b) for (long long int i = a; i < b; i++)
#define for2(i, a, b) for (long long int i = a; i > b; i--)
//  cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;typedef long long int i;
typedef long long int lli;
typedef pair<lli, lli> pll;
map<lli, lli> m;
vector<lli> v1;
lli infi = 3234566667;
lli create(lli n)
{
    if (n % 10 != 9)
    {
        lli a = n * 10 + n % 10 + 1;
        if (m[a] == 0 && a <= infi)
        {
            v1.pb(a);
            m[a] = 1;

            create(a);
            // m[a] =1;
        }
    }
    lli b = n * 10 + n % 10;
    if (n % 10 != 0)
    {
        lli c = n * 10 + n % 10 - 1;
        if (m[c] == 0 && c <= infi)
        {
            m[c] = 1;
            v1.pb(c);
            create(c);
        }
    }

    if (m[b] == 0 && b <= infi)
    {
        m[b] = 1;
        v1.pb(b);
        create(b);
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    for1(i, 1, 10)
    {
        m[i] = 1;
        v1.pb(i);
        create(i);
    }
    sort(all(v1));

    lli k;
    cin >> k;
    cout << v1[k - 1] << endl;
}

Measured memory_bytes: 19188
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    string s;
    cin >> s;
    int n = s.size();

    int ans = 0;
    int len = 0;
    for(int i=0; i<n; ++i){
        if(string("ACGT").find(s[i]) == string::npos){
            len = 0;
        }
        else{
            ++ len;
            ans = max(ans, len);
        }
    }
    cout << ans << endl;

    return 0;
}


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

#define INFint 2e9+1

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

int main(){
// start
  struct edge {int to,cost;};
  int N;
  cin>>N;
  vector<vector<edge>> G(N,vector<edge>());
  for(int i(0);i<N;i++){
    int k,u;
    cin>>k>>u;
    for(int j(0);j<u;j++){
      int v,c;
      cin>>v>>c;
      G[k].push_back({v,c});
    }
  }
  vector<int> d(N); //各頂点の最小値を入れる配列
  fill(d.begin(),d.end(),INFint);
  // first: cont, second: node number 
  priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> q;
  int start = 0;
  d[start] = 0;
  q.push({0,start});

  while(!q.empty()){
    pair<int,int> p = q.top();q.pop();                                                  
    int v = p.second;
    if (d[v] < p.first) continue;
    for (int i(0);i<int(G[v].size());i++){
      edge e = G[v][i];
      if (d[e.to] > d[v] + e.cost){
        d[e.to] = d[v] + e.cost;
        q.push({d[e.to],e.to});
      }
    }
  }
// end
  for(int i(0);i<N;i++){
    cout << i <<" " << d[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 3172
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>

using namespace std;

const int N = 100010;

int main()
{
    int n;
    scanf("%d", &n);
    
    for(int i = 0; i < 1 << n; i ++)
    {
        printf("%d:", i);
        for(int j = 0; j < n; j ++)
            if(i >> j & 1)  printf(" %d", j);
        puts("");
    }
    return 0;
}


Measured memory_bytes: 3220
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <algorithm>
#include <unordered_map>
#define int                long long
#define pb                 push_back
#define pi                 pair<int,int>
#define vi                 vector<int>
#define all(v)             v.begin(),v.end()
#define modd               1000000009
#define F                  first
#define S                  second
#define FOR(i,r)           for(int i=0;i<r;i++)
#define rep(i,l,r)         for(int i=l;i<r;i++)
#define rer(i,l,r)         for(int i=l;i>=r;i--)
#define print(v)           for(auto i : v)cout << i << ' ';
#define FASTIO             ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mem(arr,k)         memset(arr,k,sizeof(arr));
#define pii                acos(-1.0)
#define PI                 3.1415926535897932385
#define Sin(a)             sin((pi*a)/180)
using namespace std;
char mat[50][50];
int n,m;
int dr[]={-1,1,0,0};
int dc[]={0,0,1,-1};
int bfs(int x,int y){
	queue<pi>q;
	q.push({x,y});
	bool vis[51][51];
	mem(vis,0);
	vis[x][y]=1;
	int level[51][51];
	mem(level,0);
	level[x][y]=0;
	int ans=0;
	while(!q.empty()){
		pi node = q.front();
		q.pop();
		for(int u=0;u<4;u++){
			int xx = node.F+dr[u];
			int yy = node.S+dc[u];
			if(xx<0 || yy<0 || xx>=n || yy>=m || vis[xx][yy] || mat[xx][yy]=='#')
				continue;
			q.push({xx,yy});
			vis[xx][yy]=1;
			level[xx][yy]=level[node.F][node.S]+1;
			ans=max(ans,level[xx][yy]);
		}
	}
	return ans;

}
int32_t main(){

	
	FASTIO;
//	int h,w;
	cin >> n >> m;
	FOR(i,n)
	{
		FOR(j,m){
			cin >> mat[i][j];
		}
	}
	int fans=-1;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(mat[i][j]=='.'){
				fans=max(fans,bfs(i,j));
			}
		}
	}
	cout << fans << endl;
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(x) x.begin(),x.end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

int n;
vector<ll>a,ans;
ll sum=0;

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

    cin>>n;
    a.resize(n);
    rep(i,n){
        cin>>a[i];
        sum^=a[i];
    }
    rep(i,n){
        ans.push_back(sum^a[i]);
    }
    rep(i,n){
        if(i!=n-1)cout<<ans[i]<<" ";
        else cout<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 6888
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();

		List<Integer> P = new ArrayList<>();
		List<Integer> Q = new ArrayList<>();

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

		sc.close();

		List<Integer> l = new ArrayList<>();
		for (int i = 1; i <= N; i++) {
			l.add(i);
		}

		List<List<Integer>> x = permutations(l, N);

		x.sort((a, b) -> a.toString().compareTo(b.toString()));

		int a = 0, b = 0;
		for (int i = 0; i < x.size(); i++) {
			if (P.equals(x.get(i))) {
				a = i;
			}
			if (Q.equals(x.get(i))) {
				b = i;
			}
		}

		out.println(Math.abs(a - b));

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

	private static <T> List<List<T>> permutations(List<T> l, int r) {
		if (r == 0) {
			return new ArrayList<List<T>>() {
				{
					add(new ArrayList<T>());
				}
			};
		}

		List<List<T>> result = new ArrayList<>();

		for (int i = 0; i < l.size(); i++) {
			T a = l.get(i);
			List<T> ll = new ArrayList<>(l);
			ll.remove(i);

			List<List<T>> s = permutations(ll, r - 1);
			for (List<T> ss : s) {
				List<T> z = new ArrayList<>();
				z.add(a);
				z.addAll(ss);
				result.add(z);
			}

		}

		return result;
	}
}


Measured memory_bytes: 66644
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
const int maxn = 98;
char num[maxn + 5][maxn + 5];
int A, B;
bool flag;
int main() {
	scanf("%d%d", &A, &B);
	if(A > B) {
		flag = true;
		swap(A, B);
	}
	int cnt_A = 0, cnt_B = 0;
	for(int i = 1; i <= maxn; i++)
		for(int j = 1; j <= maxn; j++)
			num[i][j] = '.';
	if(cnt_A < A - 1) {
		for(int i = 2; i <= maxn; i += 2) {
			num[1][i] = num[2][i - 1] = '#';
			cnt_A++;
			cnt_B++;
			if(cnt_A == A - 1) {
				for(int j = 2; j <= i; j += 2)num[2][j] = '#';
				cnt_B -= (i / 2);
				cnt_B++;
				break;
			}
		}
	}
	if(cnt_A < A - 1) {
		int l;
		for(int i = 3; i <= maxn; i++) {
			if(cnt_A == A - 1) break;
			if(i & 1)l = 2;
			else l = 1;
			for(int j = l; j <= maxn; j += 2) {
				num[i][j] = '#';
				cnt_A++;
				cnt_B++;
				if(cnt_A == A - 1) {
					for(int k = 1; k <= j; k++)num[i][k] = '#';
					for(int k = j + 1; k <= maxn; k++)num[i - 1][k] = '#';
					cnt_B -= (maxn / 2 - 2);
					break;
				}
			}
		}
	}
	for(int i = maxn; i >= 1; i -= 2) {
		if(cnt_B == B)break;
		for(int j = 1; j <= maxn; j += 2) {
			if(cnt_B == B)break;
			num[i][j] = '#';
			cnt_B++;
		}
	}
	printf("%d %d\n", maxn, maxn);
	for(int i = 1; i <= maxn; i++) {
		for(int j = 1; j <= maxn; j++)
			if(flag == true) {
				if(num[i][j] == '.')printf("#");
				else printf(".");
			}
			else printf("%c", num[i][j]);
		printf("\n");
	}
	return 0;
}

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

#define ENGZ ios::sync_with_stdio(0);cin.tie(0);ios_base::sync_with_stdio(0);
#define sfi(x) scanf("%d" , &x)
#define sfi2(x, y) scanf("%d%d" , &x,&y)
#define sfl2(x, y) scanf("%I64d%I64d" , &x,&y)
#define sfl(x) scanf("%I64d" , &x)
#define sfl3(x, y, z) scanf("%I64d%I64d%I64d", &x, &y, &z)
#define sfd(x) scanf("%lf", &x)
#define sfd2(x, y) scanf("%lf", &x, &y)
#define sfc(x) scanf("%c", &x)
#define testv(x) cerr << x << ' '
#define wtf(s) freopen((s), "w", stdout)
#define rff(s) freopen((s), "r", stdin)
#define test cerr << "here"
#define mod 1000000007
#define pi (2*acos(0))
typedef long double ld;
typedef long long ll;

int n;
ll a[3003], dp[3003][3003][2];
ll solve(int l, int r, int p)
{
    if (l > r)
        return 0;
    if (dp[l][r][p] != -1)
        return dp[l][r][p];
    if (p)
        return dp[l][r][p] = max(solve(l + 1, r, !p) + a[l], solve(l, r - 1, !p) + a[r]);
    else
        return dp[l][r][p] = min(solve(l + 1, r, !p) - a[l], solve(l, r - 1, !p) - a[r]);
}

int main()
{
    cin >> n;
    memset(dp, -1, sizeof dp);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    cout << solve(0, n - 1, 1);
    return 0;
}

Measured memory_bytes: 141312
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPR(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(x) ll(x.size()) 
using P = pair<int, int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 2e9;
const ll LINF = (1LL<<60);

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s,t;
  cin >> s >> t;

  int ans = INF;
  REP(i,s.size()){
    string st = s.substr(i,t.size());
    if(st.size()<t.size()) break;
    int tmp = 0;
    REP(j,t.size()) if(st[j]!=t[j]) tmp++;
    chmin(ans, tmp);
  }
  cout << ans << '\n';
  return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  
  vector<int> h(N);
  int ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> h.at(i);
    if (h.at(i) >= K) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char s[200002][15];
int cmp(const void * a, const void *b){return strcmp(s[*(int*)a],s[*(int*)b]);}
int main(){
    int n;
    scanf("%d",&n);
    int c[200003];
    for(int i = 0; i < n; i++){
        scanf("%s",s[i]);
        c[i] = i;
    }
    qsort(c,n,4,cmp);
    int a[200003];
    a[c[0]] = 1;
    for(int i = 0; i < n; i++){
        if(strcmp(s[c[i]], s[c[i - 1]]) == 0)
            a[c[i]] = a[c[i - 1]] + 1;
        else 
            a[c[i]] = 1;
    }
    int max = 0;
    for(int i = 0; i <n; i++)
        if(a[i] > max)
            max = a[i];
    for(int i = 0; i < n; i++)
        if(a[c[i]] == max)
            printf("%s\n",s[c[i]]);
    return 0;
}

Measured memory_bytes: 6388
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
int X[51],Y[51];
P p[51];

signed main(){
	cin>>N;
	REP(i,N){
		cin>>X[i]>>Y[i];
		p[i]=make_pair(X[i],Y[i]);
	}
	sort(p,p+N);
	vector<P> v;
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			v.push_back(make_pair(p[j].first-p[i].first,p[j].second-p[i].second));
		}
	}
	int ans=N;
	for(int i=0;i<v.size();i++){
		int cnt=0;
		for(int j=0;j<N;j++){
			for(int k=j+1;k<N;k++){
				if(p[k].first-p[j].first==v[i].first&&p[k].second-p[j].second==v[i].second){
					cnt++;
				}
			}
		}
		ans=min(ans,N-cnt);
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;
typedef long long ll;

const int N = 200005;

char s[N];
int n;

int main(){

    scanf("%s", s);

    ll ans = 0, cnt = 0;

    for(int i = 0; s[i]; i++){
        if(s[i] == 'B') cnt++;
        else ans += cnt;
    }

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

}


Measured memory_bytes: 384
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));
  $n=intval($n);

  $route=[];
  for ($i=1; $i<$n; $i++) {
    list($a,$b,$c) = explode(" ", trim(fgets(STDIN)));
    $a=intval($a);
    $b=intval($b);
    $c=intval($c);
    if(!isset($route[$a])) $route[$a]=[];
    if(!isset($route[$b])) $route[$b]=[];
    $route[$a][$b]=$c;
    $route[$b][$a]=$c;    
  }

  list($Q,$k) = explode(" ", trim(fgets(STDIN)));
  $Q=intval($Q);
  $k=intval($k);

  $q=new SplQueue();

  $q->enqueue($k);

  $d = [];
  $d[$k]=0;
  while($q->count() > 0){
    $i = $q->dequeue();
    $e = $d[$i];
    $nexts = $route[$i];
    foreach($nexts as $key => $value){
      if(!isset($d[$key])){
        $d[$key] = $e + $value;
        $q->enqueue($key);
      }
    }
  }

//  var_dump($d);

  for($i=0; $i<$Q; $i++){
    list($x,$y) = explode(" ", trim(fgets(STDIN)));
    echo $d[$x]+$d[$y];
    echo PHP_EOL;
  }

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

int main()
{
  ll A, B, C;
  ll ans, tmp;
  cin >> A >> B >> C;
  tmp =  min(C,B);
  ans = tmp * 2;
  C -= tmp;
  B -= tmp;
  if(C>0) {
    tmp = min(C,A);
    ans += tmp;
    C -= tmp;
    A -= tmp;
  }
  if(C>0) { ans++; }
  if(B>0) { ans+=B; }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <vector> 
#include <numeric>
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long

using namespace::std;

int jo(ll int jxo, ll int jyo){
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){
  return (toxbig-0x20);
}
char tolow(char toxlow){
  return (toxlow+0x20);
}
  


int main(){
  int a,b;
  cin>>a>>b;
  if((a+b)%2) cout<<(a+b+1)/2;
  else cout<<(a+b)/2;

}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define PB(x)	push_back(x)
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x)	(x).rbegin(), (x).rend()
#define MP(x)	make_pair(x)
 
#define debug(_x)		cerr << #_x << '=' << _x << endl;
#define debug2(_x, _y)	cerr << #_x << '=' << _x << ' ' << #_y << '=' << _y << endl;
#define debugn(_a)		cerr << #_a << ": "; for (const auto _x: _a) cerr << _x << ' '; cerr << endl;

#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)

#define int long long int

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef unsigned long long ull;
 
const int INF = LONG_LONG_MAX;
const int NINF = LONG_LONG_MIN;

int32_t main() {
	FAST_IO;
	
	string s;
	cin >> s;
	
	for (int i = 0; i < (int)s.size(); i++) {
		if (s[i] == '7') {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}
// g++ -Wall -Wextra -Wshadow -fsanitize=undefined



Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long MOD = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  int N, K;
  cin >> N >> K;
  vector<int> l(N);
  for (int i = 0; i < N; i++) cin >> l.at(i);
  
  sort(l.begin(), l.end(), greater<int>());
  
  int ans = 0;
  for (int i = 0; i < K; i++) ans += l.at(i);
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

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

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

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

    queue<P> que;
    que.emplace(0, 0);
    vector<int> dist(n, inf);
    dist[0] = 0;
    vector<int> ans(n, -1);
    while(que.size()){
        int cv, ccnt;
        tie(cv, ccnt) = que.front(); que.pop();

        for(auto nv : G[cv]){
            if(dist[nv] > dist[cv] + 1){
                dist[nv] = dist[cv] + 1;
                ans[nv] = cv;
                que.emplace(nv, dist[nv]);
            }
        }
    }

    bool valid = true;
    for(int i=1; i<n; i++){
        if(ans[i] == -1) valid = false;
    }

    if(!valid){
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
    for(int i=1; i<n; i++) cout << ans[i] + 1 << endl;

    return 0;
}

Measured memory_bytes: 10856
/*
 * c.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int N = 3;

/* typedef */

/* global variables */

int as[N];

/* subroutines */

/* main */

int main() {
  for (int i = 0; i < N; i++) cin >> as[i];
  sort(as, as + N);

  for (int i = 0; i < N; i++) {
    if (i) putchar(' ');
    printf("%d", as[i]);
  }
  putchar('\n');

  return 0;
}

Measured memory_bytes: 1160
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int k;
	cin >> k;
	string s;
	cin >> s;
	if(s.size() <= k) cout << s << endl;
	else cout << s.substr(0, k) << "..." << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 3656
import Data.List

main::IO()
main = do
    s <- words <$> getLine
    let [a,b] = map read s :: [Int]
    let x = map floor [x | x<-[1..1250], (floor (x*0.08))==a]
    let y = map floor [y | y<-[1..1000], (floor (y*0.1 ))==b]
    print $ if (intersect x y) == [] then -1 else minimum $intersect x y

Measured memory_bytes: 4232
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0

using namespace std;
using ll = long long;

void testcase() {
    ll a;
    string b;
    cin >> a >> b;

    string val = "abc";
    val[0] = b[0];
    val[1] = b[2];
    val[2] = b[3];

    ll b1 = atoll(val.c_str());
    ll res = a * b1;
    val = to_string(res);
    int len = val.size();
    if (len <= 2) {
    	cout << 0 << "\n";
    	return;
    }
    for (int i=0; i<len-2; i++)
    	cout << val[i];
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 3724
from collections import deque
s = list(input())
queue = deque(s)

q = int(input())
rev_count = 0
for i in range(q):
    query = list(input().split(" "))
    if len(query) == 1:
        rev_count += 1
    else:
        if query[1] == "1":
            if rev_count % 2==0:
                queue.appendleft(query[2])
            else:
                queue.append(query[2])
        else:
            if rev_count % 2==0:
                queue.append(query[2])
            else:
                queue.appendleft(query[2])

queue = "".join(list(queue))
if rev_count % 2 == 0:
    print(queue)
else:
    print(queue[::-1])


Measured memory_bytes: 15116
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    string s; cin >> s;
    int N = s.length();

    bool ok = true;
    if(s[0] == '0' or s[N-1] == '1') ok = false;
    for(int i=0; i<N-1; i++) {
        int A = i, B = N-i-2;
        if(((s[A] - '0') ^ (s[B] - '0')) == 1) ok = false;
    }

    if(ok == false) {
        cout << -1 << endl;
    }
    else {
        int cur = 0, last = -1;
        for(int i=0; i<N; i++) {
            cur = max(cur, i);
            while(cur < N and s[cur] == '0') cur++;
            
            if(s[i] == '1') {
                if(last >= 0) printf("%lld %lld\n", last+1, i+1);
                last = i;
            }
            else {
                if(cur == N) cur = last;
                printf("%lld %lld\n", i+1, cur+1);
            }
        }
    }
    return 0;
}

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

/*int n;
  cin >> n;
  vector<int> h(n);*/

int main() {

  int n, k;
  int count=0;

  cin >> n >> k;
  vector<int> h(n);

  for(int i=0;i<n;i++){
    cin >> h[i];
  }

  for(int i=0;i<n;i++){
    if(h[i] >= k){
      count++;
    }
  }

  cout << count << endl;


  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <cmath>

using namespace std;

int root(int par[], int x) {
    if (par[x] == x) return x;
    
    par[x] = root(par, par[x]);
    return par[x];
}

bool isSameRoot(int par[], int x, int y) {
    return root(par, x) == root(par, y);
}

void unite(int par[], int size[], int x, int y) {
    x = root(par, x);
    y = root(par, y);
    if (x == y) return;

    par[x] = y;
    root(par, x);
    size[y] = size[x] + size[y];
    size[x] = size[y];
}

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

    int par[N+1]; // 根を保存
    int size[N+1];
    for (int i = 1; i <= N; i++) {
        par[i] = i;
        size[i] = 1;
    }

    long ans[M];
    ans[M-1] = N*(N-1) / 2; // nC2
    for (int i = M-1; i >= 0; i--) {
        if (isSameRoot(par, A[i], B[i])) {
            ans[i-1] = ans[i];
        } else {
            ans[i-1] = ans[i] - size[root(par, A[i])] * size[root(par, B[i])];
            unite(par, size, A[i], B[i]);
        }
    }

    for (int i = 0; i < M; i++) {
        cout << ans[i] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define vvv(type, c, m, n, l, i) vector<vector<vector<type>>> c(m, vector<vector<type>>(n, vector<type>(l, i)));
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a); i>n; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
int main() {
	int n, m, l; cin >> n >> m >> l;
	mat(ll, a, n, m);
	mat(ll, b, m, l);
	vv(ll, c, n, l, 0LL);
	rep(i, 0, n) {
		rep(j, 0, l) {
			rep(k, 0, m) {
				c[i][j] += a[i][k] * b[k][j];
			}
		}
	}
	rep(i, 0, n) {
		rep(j, 0, l) {
			cout << c[i][j];
			if (j != l - 1) cout << " ";
		}
		P("");
	}
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> arr(n);
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  sort(arr.begin(), arr.end());
  int res = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      int min_k = distance(arr.begin(), lower_bound(arr.begin(), arr.end(), arr[j] - arr[i] + 1));
      int max_k = distance(arr.begin(), lower_bound(arr.begin(), arr.end(), arr[i] + arr[j]));
      res += max(0, max_k - max(j + 1, min_k));
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 256
//#include <cstdio>
#include <iostream>

#include <cstring>

#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cassert>

using namespace std;

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

int N;
llong K;
VI A, F;

bool check(llong target) {
   llong remK = K;
   REP(i, N) {
      llong max_a = target / F[i];
      llong delta = max(A[i] - max_a, 0LL);
      remK -= delta;
      if (remK < 0)
         return false;
   }
   return true;
}

llong solve() {
   sort(A.begin(), A.end());
   sort(F.begin(), F.end(), greater<int>());

   llong lo = 0, hi = 1e12+100;
   llong res = -1;
   while (lo <= hi) {
      llong mid = lo + (hi - lo) / 2;
      if (check(mid)) {
         res = mid;
         hi = mid-1;
      }
      else {
         lo = mid+1;
      }
   }
   return res;
}

int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);

   cin >> N >> K;
   A = VI(N);
   REP(i, N)
      cin >> A[i];

   F = VI(N);
   REP(i, N)
      cin >> F[i];

   llong res = solve();
   cout << res << '\n';

   return 0;
}


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

using namespace std;

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

void solve() {
  int n;
  cin >> n;
  int odd = 0;
  while(n--) {
    int a;
    cin >> a;
    odd += a%2;
  }
  if(odd%2) cout << "NO\n";
  else cout << "YES\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

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

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


int main()
{
	ll a, b, n;
	cin >> a >> b >> n;

	ll x = min(b - 1, n);
	println((a * x / b) - a * (x / b));
}

Measured memory_bytes: 3488
#include <iostream>
using namespace std;
 
int N, M;
int WA[105000];
bool AC[105000];
 
void solve() {
    cin >> N >> M;
    int WAnum = 0;
    int ACnum = 0;
    for(int i = 1; i <= N; i++) {
        WA[i] = 0;
        AC[i] = false;
    }
    while(M--) {
        int p;
        string S;
        cin >> p >> S;
        if(AC[p]) continue;
        if(S == "AC") {
            AC[p] = true;
            ACnum++;
            WAnum += WA[p];
        } else if(S == "WA") {
            WA[p]++;
        }
    }
    cout << ACnum << " " << WAnum << endl;
    return;
}
 
int main() {
    solve();
    return 0;
}

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

using namespace std;

int main()
{
    string s;
    int n,l,i=-1,c=0;
    cin>>n>>s;
    while(s[++i]!='\0'){

        if (s[i]=='R')++c;

    }
    if (c>(n-c))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256