akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define LL long long 
#define N 1000005
using namespace std;
LL int n,ar[N],sum;
char c[N];
int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&ar[i]);
	for(int i=1;i<=n;i++)
	{
		sum+=ar[i]/2;
		if(ar[i]%2 && ar[i+1])
			sum++,ar[i+1]--;
	}
	//~ for(int i=1;i<=n;i++)
	//~ {
		//~ if(ar[i]==1 && ar[i+1]==1)
			//~ sum++,ar[i+1]=0,ar[i]=0;
	//~ }
	printf("%lld",sum);
}


Measured memory_bytes: 1024
#include <iostream>
#include <string.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <vector>
#include <map>

using namespace std;

#define cn cout << '\n'
#define cio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long
#define ii pair < int, int >
#define iii pair < int, ii >
#define INF 987654321
#define LINF 987654321987654321

int main() {
    cio;
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); ++i)
        s[i] = 'x';
    cout << s;
    cn;
}


Measured memory_bytes: 3128
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

public class Main {
    private static int count = 0;
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();

        Queue<Integer> queue = new PriorityQueue<>(Comparator.reverseOrder());

        for (int i=0; i<N; i++) {
            queue.add(scanner.nextInt());
        }
        for (int i=0; i<M; i++) {
            queue.add(queue.poll()>>1);
        }
        System.out.println(queue.stream().mapToLong(x -> x).sum());
    }
}

Measured memory_bytes: 53404
#include <iostream>
#include <cstdint>
#include <algorithm>
#include <cmath>

using namespace std;

template <typename T>
T gcf(T a, T b)
{
    if (b % a == 0)
    {
        return a;
    }

    return gcf(b % a, a);
}

int main()
{
    int N, X;
    int x[100'000];

    cin >> N >> X;
    for (int i = 0; i < N; i++)
    {
        cin >> x[i];
        x[i] = abs(x[i] - X);
    }

    int d = x[0];
    for (int i = 0; i < N; i++)
    {
        d = gcf(d, x[i]);
    }

    cout << d << endl;
    return 0;
}


Measured memory_bytes: 640
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        int ans = n * n * n;
        System.out.println(ans);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 20180
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;

int main() {
  ll n,m;cin >> n>> m;
  vector<bool> canmove(n+1,true);
  for(ll i=0;i<m;++i){
    ll t;cin>>t;
    canmove[t] = false;
  }
  ll dp[n+1];
  for(ll i=0;i<=n;++i) dp[i] = 0;
  if(canmove[1]) dp[1]=1;
  if(canmove[2]) dp[2]= dp[1]+1;
  for(ll i=3;i<=n;++i){
    if(canmove[i]) dp[i]= (dp[i-1]+dp[i-2])%mod;
  }
  cout << dp[n] << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main()
{
    int s[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    int k;

    scanf("%d",&k);
    printf("%d",s[k - 1]);
}


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

using namespace std;

#define forn(i,n) for ( int i=0 ; i < n ; i++ )
#define all(a) (a).begin(), (a).end()
#define lb lower_bound
#define ub upper_bound
#define vi vector<int >
#define pii pair<int, int>
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SQ(a) (a)*(a)
#define ll long long
#define lli long long int
#define ull unsigned long long
#define endl '\n'
#define Pi(a) printf("%d\n",a);
#define debug2(a,b) printf("%d\t%d\n",a,b);
#define debug1(a) printf("%d\n",a);
#define Si(a) scanf("%d",&a);
#define mod 1000000007
#define w(n) while(n--)



int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	//code
	ll n,m,ans;
	cin >> n >> m;
	ll arr[n];
	forn(i,n) cin>> arr[i];
	map<ll,ll> mp;
	ll pre=0;
	forn(i,n){
		pre+=arr[i];
		mp[pre%m]++;
	}
	ans=0;
	ans+=mp[0];
	for(auto it:mp){
		if(it.S>1){
			ans+=((it.S)*(it.S-1))/2;
		}
	}
	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;
int main(int argc, char const *argv[]) {
  ll a, b, c;std::cin >> a >> b >> c;
  std::cout << (a==b&&b==c?"Yes":"No") << '\n';
}


Measured memory_bytes: 256
/*
                                                     _         _   _
                                                    (_)       | | | |
 _ __  _ __ ___   __ _ _ __ __ _ _ __ ___  _ __ ___  _ ___ ___| |_| |_
| '_ \| '__/ _ \ / _` | '__/ _` | '_ ` _ \| '_ ` _ \| / __/ __| __| __|
| |_) | | | (_) | (_| | | | (_| | | | | | | | | | | | \__ \__ \ |_| |_
| .__/|_|  \___/ \__, |_|  \__,_|_| |_| |_|_| |_| |_|_|___/___/\__|\__|
| |               __/ |
|_|              |___/



*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>                 /// жыве беларусь
#include <ext/pb_ds/tree_policy.hpp>

//#pragma GCC optimize("Ofast")
//#pragma optimize("O3")

typedef long long ll;
typedef unsigned long long ull;

using namespace std;
using namespace __gnu_pbds;

#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ff first
#define ss second
#define ss1 second.first
#define ss2 second.second
#define forn(i, n) for(int i=0;i<n;i++)
#define fore(i, l, r) for(int i=l;i<r;i++)
#define pi pair<int,int>
#define pl pair<ll,ll>
#define vi vector<int>
#define vpi vector<pi>
#define gcd(a,b) __gcd(a,b)
#define FASTIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define smp(x,y) {min(x,y),max(x,y)}
#define sqr(x) ((x)*(x))
#define newstr cout << "\n"
#define call(a) {for(auto xxx:a)cout<<xxx<<" ";cout<<"\n";}
#define sz(a) (ll)a.size()
#define FILE
const string alf = "abcdefghijklmnopqrstuvwxyz";
const int hashP = 1e9+7;
const int hashP2 = 239017;
const int N = 1e5+10;
const int MOD = 1e9 + 7;
const int MOD2 = 998244353;
const int INF = 1e9;
const ll oo = 9e18;

template<typename T>
bool umn(T &a, T b) { return (a > b ? (a = b, 1) : 0); }
template<typename T>
bool umx(T &a, T b) { return (a < b ? (a = b, 1) : 0); }

template<typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; // order_of_key    find_by_order

void solve() {
    string s;
    cin >> s;
    ll ans=0,cnt=0;
    for(int i=0;i<3;i++) {
        if(s[i]=='R') {
            cnt++;
            umx(ans,cnt);
        } else {
            cnt=0;
        }
    }
    cout << ans << "\n";
}

int main() {

    FASTIO;

#ifndef FILE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif

    ll tt;
    tt=1;
    //cin >> tt;
    while(tt--) {
        solve();
    }

    return 0;
}
/**
tests
************

3 3

1000000000 1000000000 2

2 994305000
922337204 1000000000

************
**/


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define fname "D"
#define ll long long
#define ui unsigned int
#define ull unsigned long long
#define bug(x) cerr << (#x) << " = " << (x) << '\n'
#define REP0(i, n) for(int i = 0, _n = (n); i < _n; ++i)
#define REP1(i, n) for(int i = 1, _n = (n); i <= _n; ++i)
#define REPB0(i, n) for(int i = (n) - 1; i >= 0; --i)
#define REPB1(i, n) for(int i = (n); i > 0; --i)
#define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; ++i)
#define FORB(i, a, b) for(int i = (a), _b = (b); i >= _b; --i)
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define X first
#define Y second

using namespace std;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef pair<float, float> ff;
typedef pair<double, double> dd;

int main()
{
	if (fopen(fname".INP", "r")) {
		freopen(fname".INP", "r", stdin);
		freopen(fname".OUT", "w", stdout);
	}
	ios_base::sync_with_stdio(false); cin.tie(0);
	string s;
	cin >> s;
	REP0(i, s.size() - 1) {
		if (s[i] == s[i + 1]) {
			cout << i + 1 << ' ' << i + 2;
			return 0;
		}
	}
	REP0(i, s.size() - 2) {
		if (s[i] == s[i + 2]) {
			cout << i + 1 << ' ' << i + 3;
			return 0;
		}
	}
	cout << "-1 -1";
	return 0;
}

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

using namespace std;

int main(){
	ios::sync_with_stdio(false);	
	cin.tie(0);
	string s;
	cin >> s;
	string ans = "";
	for (char c : s){
		if (c == '0'){
			ans += '0';
		}	
		if (c == '1'){
			ans += '1';
		}
		if (c == 'B' && !ans.empty()){
			ans.erase(ans.begin() + ans.size()-1);
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define add push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n";
using ll = long long;
const int INF = 0x3f3f3f3f;

int n, W;
ll v[101], w[101], dp[102][100001];

ll solve(int i = n, ll rem = W) {
    if (rem==0 || i == 0) {
        return 0;
    }
    ll& ret = dp[i][rem];
    if (~ret) {
        return ret;
    }
    return ret = max(solve(i-1, rem), w[i-1]<=rem? v[i-1]+solve(i-1, rem-w[i-1]) : 0);
     
}
int main() {
    IOS
    cin >> n >> W;
    memset(dp, -1, sizeof dp);
    for (int i = 0; i < n; ++i) {
        cin >> w[i] >> v[i];

    }
    cout << solve() << endl;
    
    return 0;
}






Measured memory_bytes: 80000
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS                       \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);
//#define mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x, y) memset(x, y, sizeof(x))
#define pb push_back
#define mk make_pair
#define pi pair<int, int>
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = a; i >= (b); --i)
using namespace std;
int dt[][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}, {0, 0}};
//typedef pair<int, int> P;
//priority_queue<int, vector<int>, greater<int> > q;
int main()
{
    IOS;
    int k;
    cin >> k;
    int ans = 1;
    for (int mod = 7; mod % k; mod = (mod * 10 + 7) % k)
    {
        if (++ans > k)
        {
            ans = -1;
            break;
        }
    }
    cout << ans;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int main()
{
	char a,b,c,d;
	scanf("%c%c%c%c",&a,&b,&c,&d);
	if(((a==b&&c==d)||(a==c&&b==d)||(a==d&&b==c))&&!(a==b&&b==c&&c==d))
		printf("Yes");
	else
		printf("No");
    return 0;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;
ll n,m;
vector<vector<ll>> graph(1e5);
vector<ll> dp(1e5,-1);

ll rec(ll now)
{
    if(dp.at(now) != -1) return dp.at(now);
    ll ans = 0;
    for(auto x: graph.at(now)){
        ans = max(ans, rec(x)+1);
    }
    return dp.at(now) = ans;
}

int main()
{
    ll i,j;
    
    cin >> n >> m;
    for(i = 0;i < m;++i){
        ll x,y;
        cin >> x >> y;
        --x;    --y;
        graph.at(x).push_back(y);
    }
    ll ans = 0;
    for(i = 0;i < n;++i){
        ans = max(ans, rec(i));
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8576
#include<stdio.h>
#define MAX 10000

int solve(int,int);

int n,A[MAX];

int main(){
  int i,j;
  int m,key,sum=0;
  
  scanf("%d",&n);

  for( i = 0 ; i < n ; i++ ){
    scanf("%d",&A[i]);
  }

  scanf("%d",&m);

  for( j = 0 ; j < m ; j++ ){
    scanf("%d",&key);

    if( solve(0,key) != 0) printf("yes\n");

    else printf("no\n");

    
  }

  return 0;
}

int solve(int i , int m){
  if( m == 0 ) return 1;

  if( i >= n ) return 0;

  int res = solve( i+1,m ) || solve( i+1,m-A[i]);
  return res;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b)
{
    if(b==0)
        return a;
    return 
        gcd(b,a%b);
}
int main()
{
	long n,m;
	cin>>n>>m;
	cout<<((n*m)/gcd(n,m));
}

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

typedef long long   ll;
const ll mod = 1e9 + 7;

#define speedup_IO      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n)     for(ll i = a; i < n; i++)
#define ford(i,n,a)     for(ll i = n-1; i >= a; i--)
#define pb              push_back
#define lb              lower_bound
#define ub              upper_bound
#define pll             pair<ll,ll>
#define all(a)          (a).begin(),(a).end()
#define reset(a,x)      memset(a,x,sizeof(a))

ll mypow(ll base, ll exp) {ll res = 1; while (exp) {if (exp & 1) res = (res * base) % mod; exp >>= 1, base = (base * base) % mod;} return res;}
ll gcd(ll a, ll b)  { return b ? gcd(b, a % b) : a;            }
ll mult(ll a, ll b) { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b)  { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return (a % mod + b % mod) % mod;        }
ll sub(ll a, ll b)  { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return (a % mod + mod - b % mod) % mod;  }

const ll inf = 1e18;
const int nax = 1e5 + 5;

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

	string s1="",s2="";

	forn(i,0,a)
	{
		s1+=(b+48);
	}
	forn(i,0,b)
	{
		s2+=(a+48);
	}

	if(a>b)
	{
		cout<<s1;
	}
	else
	{
		cout<<s2;
	}

	return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    H, W = map(int, input().split())
    C = [list(map(int, input().split())) for _ in range(10)]
    A = [list(map(int, input().split())) for _ in range(H)]

    for k in range(10):
        for i in range(10):
            for j in range(10):
                C[i][j] = min(C[i][j], C[i][k] + C[k][j])

    ans = 0
    for h in range(H):
        for w in range(W):
            if 0 <= A[h][w]:
                ans += C[A[h][w]][1]

    print(ans)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3444
module Main where

import Control.Applicative
import Text.Printf
import Numeric

main :: IO ()
main = do
  { [a,b] <- getInts
  ; let (x,y) = a `divMod` b
  ; let z = fromIntegral a / fromIntegral b
  ; putStrLn (unwords [ showFFloat Nothing (fromIntegral x) ""
                      , showFFloat Nothing (fromIntegral y) ""
                      , showFFloat Nothing z ""])
  }

--

getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show



Measured memory_bytes: 3932
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")

//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")

// -------------------</optimizations>--------------------
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#define d long double
#define pii pair<int,int>
#define pb push_back
#define cases int tc;cin>>tc;while(tc--)
#define N 100003
#define M 2003
#define inf 1e18
#define Arena ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//int mod=1e9+7;
//int mod=998244353;
int dp[N];

signed main()
{
    Arena
        
    int n,k;
    cin>>n>>k;
    int a[n+1],i,j;
    for(i=1;i<=n;++i)
        cin>>a[i];
    sort(a+1,a+n+1);
    
    for(j=1;j<=k;++j)
    {
        if(!dp[j])
        {
            for(i=1;i<=n;++i)
            {
                if(a[i]>j)
                    break;
                if(!dp[j-a[i]])
                {
                    dp[j]=1;
                    break;
                }
            }   
        }   
    }   
    cout<<(dp[k]?"First":"Second");
    
    
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){

	int a, b;
	int ans = -20000;

	cin >> a >> b;

	ans = max(ans, a + b);
	ans = max(ans, a - b);
	ans = max(ans, a * b);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define sim template < class c
#define ris return *this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", ", d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; it++)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s, t;
	cin >> s >> t;
	int n = s.length(), m = t.length();
	vector<vector<int>> dp(n + 1, vector<int> (m + 1, 0));
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (s[i - 1] == t[j - 1]) {
				dp[i][j] = 1 + dp[i - 1][j - 1];
			} else {
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			}
		}
	}
	int len = dp[n][m];
	string answer;
	int p = n, q = m;
	while (p > 0 && q > 0) {
		if(s[p - 1] == t[q - 1]) {
			answer += s[p - 1];
			p--;
			q--;
		} else if (dp[p - 1][q] > dp[p][q - 1]) {
			p--;
		} else {
			q--;
		}
	}
	reverse(answer.begin(), answer.end());
	cout << answer;
	
	return 0;
}


Measured memory_bytes: 35584
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
main(){
  int i,j,k=0,l=0,a=0,b=0;
  char ch;
  char str1[1001]="",str2[1001],str3[1001],str4[1001];
  scanf("%s",str1);
  scanf("%d",&j);
  for(i=0;i<j;i++){
    scanf("%s",str2);
    /* printf("%s",str2); */
    if(!strcmp(str2,"replace")){
      /* printf("matched\n"); */
      scanf("%d %d %s",&a,&b,str3);
      for(k=a;k<=b;k++)
        str1[k]=str3[k-a];
    }
    if(!strcmp(str2,"reverse")){
      /* printf("matched\n"); */
      scanf("%d %d",&a,&b);
      for(k=a;k<=b;k++)
        str3[k-a]=str1[k];
      for(k=a;k<=b;k++)
        str1[k]=str3[b-a-k+a];
    }
    if(!strcmp(str2,"print")){
      /* printf("matched\n"); */
      scanf("%d %d",&a,&b);
      for(k=a;k<=b;k++)
        printf("%c",str1[k]);
      printf("\n");
    }
    //    printf("%d %d\n",a,b);
  }
  return 0;
}

Measured memory_bytes: 1004
/// Bismillahir Rahmanir Rahim
/* Author: Mohammad Morsalin
    Dept of ICE, NSTU
*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define f0(n) for(int i=0;i<n;i++)
#define tc(t) int t;cin>>t; while(t--)
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int,vector<int>,greater<int> >
#define ms(x) memset(x,0,sizeof(x))
#define ins insert
#define ALL(v) v.begin(),v.end()
#define ii pair<int,int>
#define vii vector<ii>
#define fi first
#define se second
#define none(n)  __builtin_popcount(n);
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define PI acos(-1)
#define IOS ios::sync_with_stdio(false);
using namespace std;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const long long MOD = 1000000007;
template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}
int main()
{
    IOS
    string s;
    while(cin>>s){
        int n=s.size();
        for(int i=0;i<n;i++){
            if(s[i]=='?'){
                if(i>0 && s[i-1]=='P') s[i]='D';
                else if(i<n-1 && s[i+1]!='P')s[i]='P';
                else s[i]='D';
            }
        }
        cout << s << endl;
    }
    return 0;
}
///Alhamdulillah



Measured memory_bytes: 3784
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
    long long int n;
    scanf("%lld",&n);
    if(n%2==0) printf("%lld",n/2*(n-1));
    else printf("%lld",(n-1)/2*n);
    return 0;
}




Measured memory_bytes: 128
N=int(input())
S=input()
cnt =0
for i in range(1000):
  s=str(i).zfill(3)

  if s[0] in S:
    s_0_index = S.index(s[0])
    S_0 = S[s_0_index+1:]

    if s[1] in S_0:
      s_1_index = S_0.index(s[1])
      S_1 = S_0[S_0.index(s[1])+1:]
 
      if s[2] in S_1:
        s_2_index = S_1.index(s[2])
        S_2 = S[s_2_index+1:]
        #print(S[s_0_index]+S[s_1_index]+S[s_2_index])
        cnt+=1
print(cnt)

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;



#define INF 2000000000
#define MAX_V 10



bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

ll gcd(ll a,ll b) { return b ? gcd(b, a%b) : a; }

ll lcm(ll a,ll b){
   return a/gcd(a,b)*b;
}
const ll MAX = 5100000;
const ll MOD = 1000000007;
 
ll fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

using graph = vector<vector<ll>>;
pair<pair<ll,ll>,ll> p[100010];



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
    return 0;
}

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

int main() {
  int n,k;
  cin >> n >> k;
  int i;
  int x=1;
  for(i=0;i<n;i++){
    if(x>k){
      x=x+k;
    }else{
      x=x*2;
    }
  }
  cout << x << endl;
}


Measured memory_bytes: 256
//#pragma GCC optimize(2)
// Happy TLE and WA every day!
// by: zxb the vegetable chicken
#include<bits/stdc++.h>
#define mp              make_pair
#define rep(i,n)        for(int i = 0; i < n; i++)
#define foreach(i,c)    for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define BINF            0x7fffffff
#define INF             0x3f3f3f3f
#define LINF            4557430888798830399
#define pb              push_back
#define F               first
#define S               second
#define Time            clock()/CLOCKS_PER_SEC
#define read            ZXBs_fast_input
#define write           ZXBs_fast_output
//#define usingFiles
using namespace std;

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

inline bool read(int& x){
	x = 0;
	int c;
	int sign = 1;
	while( (c = getchar()) < '0' || c > '9' ) if(c == '-') sign = -1;
	x = c ^ '0';
	while( (c = getchar()) >= '0' && c <= '9' ) x = (x<<3) + (x<<1) + (c ^ '0');
	x *= sign;
	return 1;
}

inline bool write(int x){
	if(x >= 10) write(x / 10);
	putchar(x % 10 + '0');
	return 1;
}

const int rp = 666666;
const bool debug = 1;
const bool I_good_vegetable_a = 1;

	int cnt[10];
signed main(){
	ios::sync_with_stdio(false);
	#ifdef usingFiles
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	rep(i, 3){
		int a, b;
		cin >> a >> b;
		cnt[a - 1]++, cnt[b - 1]++;
	}
	rep(i, 4){
		if(cnt[i] > 2){
			cout << "NO\n";
			return 0;
	}
	}
	cout << "YES\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long  
#define pb push_back
#define mk make_pair
#define mod 1000000007
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define all(x) x.begin(),x.end()
#define ff first
#define ss second

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n>>k;ll as=0;
    int bit[30]={0};
    for(int i=0;i<30;i++)
    {
        if(1<<i&n)
        bit[i]=1;
    }
    ll se=1;ll w=k;
    for(int i=0;i<30;i++)
    {
        if(bit[i]==1)
        {
            se*=w;
            se%=mod;
        }
        w*=w;w%=mod;
    }
    ll ans=0;
    ll arr[k+2]={0};
    ll se1=0;
    for(int ii=k;ii>=1;ii--)
    {
        ll y=k/ii;       //cout<<y<<"ds";     //y^n
        ll ans1=1;
        ll w=y;
        for(int i=0;i<30;i++)
        {
            if(bit[i]==1)
            {
                ans1*=w;
                ans1%=mod;
            }
              w*=w;w%=mod;
         }
         ans1%=mod;
         arr[ii]=ans1;
         for(int j=2;j*ii<=k;j++)
         {
             arr[ii]-=arr[ii*j];
             arr[ii]+=mod;arr[ii]%=mod;
         }
     }
    for(int i=1;i<=k;i++)
    {
        ans+=i*arr[i];
        ans%=mod;
    }
    cout<<ans;
    
    return 0;
}
//make all values ll


Measured memory_bytes: 4416
#include<cstdio>
#include<algorithm>
int n, k;
long long ans;
long long c[200010], val[200010], sum[200010];

inline void add(long long x, long long y){
	for(;x <= n;x += x & -x) c[x] += y;
}

inline long long ask(long long x){
	long long ans = 0;
	for(;x;x -= x & -x) ans += c[x];
	return ans;
}

int main(){
	scanf("%d %d", &n, &k);
	for(int i = 1;i <= n;++i){
		scanf("%lld", &val[i]);
		val[i] -= k; 
	}
	for(int i = 1;i <= n;++i){
		sum[i] = (val[i] += val[i - 1]);
		if (sum[i] >= 0) ++ans;
	}
	std::sort(sum + 1, sum + 1 + n);int t = std::unique(sum + 1, sum + 1 + n) - (sum + 1);
	for(int i = 1;i <= n;++i) val[i] = std::lower_bound(sum + 1, sum + 1 + t, val[i]) - sum;
	for(int i = 1;i <= n;++i){
		ans += ask(val[i]);add(val[i], 1);
	}
	printf("%lld\n", ans);
	return 0;
}
/*
对区间[l, r] average = (sum[r] - sum[l - 1]) / (r - l + 1) >= k
等价于sum[r]-r*k>=sum[l-1]-(l-1)*k
*/

Measured memory_bytes: 4864
N = int(input())
S = input()
num = S[1:].count('E')
ans = [num]
for i in range(1, N):
    if S[i] == 'E':
        num -= 1
    if S[i-1] == 'W':
        num += 1
    ans.append(num)
print(min(ans))


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

int main(){
  int n;cin >> n;
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  int sum=0;
  int h,l;
  for(int i=0;i<n-2;i++){
    h=max(p[i],p[i+1]);
    h=max(h,p[i+2]);
    l=min(p[i],p[i+1]);
    l=min(l,p[i+2]);
    if(p[i+1]<h && p[i+1]>l){
      sum++;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iomanip>
#include <tuple>

using namespace std;


int main(){
   int a,p;
   cin>>a>>p;
   cout<<(a*3+p)/2<<endl;
}

   


Measured memory_bytes: 888
#include <bits/stdc++.h>
//#define int long long
#define double long double
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define fcout(n) cout << fixed << setprecision(n)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acosl(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> inline bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


int W, H;
int bld[110][110];
int dx[2][6] = { { 1, 0, -1, -1, -1, 0 }, { 1, 1, 0, -1, 0, 1 } };
int dy[2][6] = { { 0, -1, -1, 0, 1, 1 }, { 0, -1, -1, 0, 1, 1 } };


signed main(){
    cin >> W >> H;
    repe(i, 1, H) repe(j, 1, W) cin >> bld[j][i];

    int ans = 0;
    queue<PII> q;
    q.push({ 0, 0 });
    bld[0][0] = -1;
    while(!q.empty()){
        PII p = q.front(); q.pop();
        rep(k, 0, 6){
            int x = p.first+dx[p.second%2][k];
            int y = p.second+dy[p.second%2][k];
            if(!isin(x, 0, W+2) or !isin(y, 0, H+2)) continue;
            if(bld[x][y] == 0) q.push({ x, y }), bld[x][y] = -1;
            if(bld[x][y] == 1) ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


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

// clang-format off
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

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

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

void solver() {
    int N = input();
    string s = input<string>();
    vector< int > v;
    range(i, 1, N) {
        v.push_back(abs(s[i] - s[i - 1]));
    }
    
    auto lucas2 = [](i64 n, i64 k) {
        return !(~n & k);
    };

    auto f = [&]() {
        int res = 0;
        range(i, 0, v.size()) {
            (res += lucas2(v.size() - 1, i) * v[i]) %= 2;
        }
        return res;
    };

    if (f() & 1) {
        cout << 1 << endl;
        return;
    }
    
    range(i, 0, v.size()) {
        if (v[i] == 1) {
            cout << 0 << endl;
            return;
        }
        v[i] /= 2;
    }
    
    if (f() & 1) {
        cout << 2 << endl;
    } else {
        cout << 0 << endl;
    }
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 8216
#include <bits/stdc++.h>
#define simplify ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define endl "\n"
using namespace std;


int32_t main()
{
    simplify
    
    int x,n;
    cin>>x>>n;
    set<int>s;
    int temp;
    for(int i=0;i<n;i++){
        cin>>temp;
        s.insert(temp);
    }
    int add=0;
    while(true){
        if(!s.count(x-add)){
            cout<<x-add;
            return 0;
        }
        if(!s.count(x+add)){
            cout<<x+add;
            return 0;
        }

        add++;
    }



    return 0;
}


Measured memory_bytes: 3656
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//

        int A;
        cin >> A;

        if (A >= 1200)
        {
                cout << "ARC" << endl;
        }
        else
        {
                cout << "ABC" << endl;
        }

        return 0;
}


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

#define x first
#define y second
#define int64 long long
#define MaxN 200000
#define MaxV 28

map<int, int> M;
map<int, int>:: iterator it;
pair<int, int> A[MaxN+1];
pair<int, int> B[MaxN+1];
int sumB[MaxN+1];
int u[MaxN+1];
int v[MaxN+1];
int N, K;

int main(){



    int i, R, l, r, st, dr, step, ap, nA, nB, res = 0;

    scanf("%d", &N);
    for(i = 1; i <= N; ++i) scanf("%d", &u[i]);
    for(i = 1; i <= N; ++i) scanf("%d", &v[i]);
    for(step = 0; step <= MaxV; ++step)
    {
        R = (1 << step + 1);
        ap = 0;

        for(i = 1; i <= N; ++i) ++M[ u[i] % R ];
        for(nA = 0, it = M.begin(); it != M.end(); it++) A[++nA] = {it->first, it->second};
        M.clear();

        for(i = 1; i <= N; ++i) ++M[ v[i] % R ];
        for(nB = 0, it = M.begin(); it != M.end(); it++) B[++nB] = {it->first, it->second};
        M.clear();

        for(i = 1; i <= nB; ++i) sumB[i] = (sumB[i-1] + B[i].y) % 2;

        l = r = nB;
        for(i = 1; i <= nA && A[i].x <= R / 2; ++i){
            st = R / 2 - A[i].x;
            dr = (R - 1) - A[i].x;

            while(B[l].x >= st && l > 0) --l;
            while(B[r].x > dr && r > 0) --r;
            if(B[l].x < st && l < nB) ++l;

            if(l <= r && st <= B[l].x && B[r].x <= dr) ap = ap + (A[i].y % 2) * (sumB[r] - sumB[l-1]);
        }

        l = r = nB;
        for(; i <= nA; ++i){
            A[i].x = A[i].x - (R / 2);
            st = R / 2 - A[i].x;
            dr = (R - 1) - A[i].x;

            while(B[l].x >= st && l > 0) --l;
            while(B[r].x > dr && r > 0) --r;
            if(B[l].x < st && l < nB) ++l;

            if(l <= r && st <= B[l].x && B[r].x <= dr) ap = ap + (A[i].y % 2) * (sumB[nB] - (sumB[r] - sumB[l-1]));
            else ap = ap + (A[i].y % 2) * sumB[nB];
        }

        if(ap % 2) res = res | (1 << step);
    }

    printf("%d\n", res);


return 0;
}


Measured memory_bytes: 15104
#include<stdio.h>
int main(){
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if(W>=x+r&&H>=y+r&&x-r>=0&&y-r>=0){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 2616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf=0x3f3f3f3f;
ll a[3005];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    ll sum=0;
    for(int i=1;i<=n;++i){
        cin>>a[i];
        sum+=a[i]-1;
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;
using Graph = vector<vector<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 long long INF = 1LL << 60;

int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}

int digsum(int n) {
  int res = 0;
  while(n > 0) {
    res += n%10;
    n /= 10;
  }
  return res;
}

int dignum(int n) {
  int res = 0;
  while(n > 0) {
    res++;
    n /= 10;
  }
  return res;
}

int stringcount(string s, char c) {
  return count(s.cbegin(), s.cend(), c);
}

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

int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}

int main(){
  int n;
  cin>>n;
  Graph g(n);
  for(int i=0;i<n;i++){
    int num,m;
    cin>>num>>m;
    num--;
    for(int j=0;j<m;j++){
      int a;
      cin>>a;
      a--;
      g[num].pb(a);
    }
  }
  vector<int> dist(n,-1);
  queue<int> que;
  dist[0]=0;
  que.push(0);

  while(!que.empty()){
    int x=que.front();
    que.pop();
    for(int nv:g[x]){
      if(dist[nv]!=-1) continue;

      dist[nv]=dist[x]+1;
      que.push(nv);

    }
  }
  for(int i=0;i<n;i++) cout<<i+1<<" "<<dist[i]<<endl;



}


Measured memory_bytes: 3144
input = require("fs").readFileSync("/dev/stdin", "utf8")
cin = input.split(/ |\n/), cid = 0
const next = () => cin[cid++]
const nexts = (n) => cin.slice(cid, cid+=n)

var [s, t] = nexts(2)
// console.log(s, t)
console.log(s === t.slice(0, s.length) ? 'Yes' : 'No')


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


bool grid[25][25];
bool odw[25][25];

int v1[4] = {1,-1,0,0};
int v2[4] = {0,0,1,-1};

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int h, w;
	cin >> h >> w;
	for (int i = 1; i <= h; ++i)
		for (int j = 1; j <= w; ++j){
			char inp;
			cin >> inp;
			if (inp == '.')
				grid[i][j] = true;
			else
				grid[i][j] = false;
		}
	int wynik = 0;
	for (int i = 1; i <= h; ++i){
		for (int j = 1; j <= w; ++j){
			if (!grid[i][j])
				continue;

			for (int k = 1; k <= h; ++k)
				for (int l = 1; l <= w; ++l)
					odw[k][l] = false;

			queue <pair<pair<int,int>,int>> Q;
			Q.push({{i,j},0});
			while (! Q.empty()){
				int x = Q.front().first.first;
				int y = Q.front().first.second;
				int d = Q.front().second;
				Q.pop();
				if (odw[x][y])
					continue;
				odw[x][y] = true;
				wynik = max(wynik, d);
				for (int i = 0; i < 4; ++i){
					if (!grid[x+v1[i]][y+v2[i]])
						continue;
					Q.push({{x+v1[i],y+v2[i]},d+1});
				}
			}
		}
	}

	cout << wynik << "\n";

}

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

vector<string> s;
char win;

bool next(int n)
{
	if(s[n].size() == 0) return 0;
	win = s[n][0];
	s[n].erase(s[n].begin());
	return 1;
}

int main()
{
	for(int i = 0; i <= 2; i++){
		string t;
		cin >> t;
		s.push_back(t);
	}
	win = 'a';
	for(;;){
		if(next(int(win) - int('a')) == 0) break;
	}
	cout << char(int(win) + int('A') - int('a')) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ll maxn  = 3e6;
const ll mod =1e9+7;
const ld PI = acos((ld)-1);
 
#define pb(x) push_back(x);
#define endl '\n'
#define dokme(x) cout << x ;  return(0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}
 
 
 
int main(){
    migmig
 	int n;
  cin >> n;
  ll sum = 0;
  for(int i = 1 ; i <= n ; i ++) for(int j = 1 ; j <= n ; j ++) for(int k = 1 ; k <= n ; k ++) sum+=__gcd(i , __gcd(j , k));
 	cout << sum;
    return(0);
}
 
//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, life is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.
//It is important to draw wisdom from diffrent places. If you take it from only one place it becomes rigid and stale.
//kuxtal jach uts chuchul u u páajtal máak jach táaj meyajilo'ob le castigadas tumen ch'aik descansos.

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

int N;
unsigned long long int memo[100];

int main()
{
    std::cin >> N;
    memo[0] = 2;
    memo[1] = 1;
    for (int i = 2; i <= N; i++) { memo[i] = memo[i - 1] + memo[i - 2]; }
    std::cout << memo[N] << std::endl;
}


Measured memory_bytes: 256
a=int(input())
b=int(input())
c=int(input())
x=int(input())
ans=0
for i in range(a+1):
     for j in range(b+1):
          for k in range(c+1):
              if i*500+j*100+k*50==x:
                       ans+=1
print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<map>
#include<unordered_map>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef long double ld;
#define mp make_pair
#define pb push_back

#define rep(i, N) for(ll i = 0; i < N; i++)
#define repa(i, a, N) for(ll i = a; i < N; i++)
#define repr(i, N) for(ll i = N-1; i >= 0; i--)

#define drep(i, N, j, M) rep(i, N) rep(j, M)
#define trep(i, N, j, M, k, L) rep(i, N) rep(j, M) rep(k, L)

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

const double PI = 3.141592653589793;

// const ll mod = 1e9 + 7;
const ll mod = 998244353;

const ll LLMAX = numeric_limits<long long>::max();

void No() {
	cout << "No" << endl;
}

void Yes() {
	cout << "Yes" << endl;
}

ll id(char c) {
	return c - 'a';
}

bool isOK(vi& a, ll k, ll index) {
	return a[index] < k * (index + 1);
}

ll binary_search(vi& a, ll k) {
	ll left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	ll right = (ll)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		ll mid = left + (right - left) / 2;

		if (isOK(a, k, mid))
			right = mid;
		else left = mid;
	}

	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}

template<class t, class u>
ostream& operator<<(ostream& os, const pair<t, u>& p) {
	return os << "{" << p.first << "," << p.second << "}";
}

template<class t> ostream& operator<<(ostream& os, const vector<t>& v) {
	os << "{";
	for (auto e : v)os << e << ",";
	return os << "}";
}

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

	cout << ceil(N / 2.0) - 1 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N;
    cin >> N;
    vector<ll> D(N), M(N);

    ll res = 0;
    rep(i, N) {
        cin >> D[i];
        if (i % 2) res -= D[i];
        else res += D[i];
    }
    
    M[0] = res;

    repd(i, 1, N) {
        M[i] = 2 * D[i - 1] - M[i - 1];
    }

    rep(i, N) cout << M[i] << endl;

    return 0;
}

Measured memory_bytes: 4836