akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

#define MAX_MATRIX 100

int main(void)
{
        int n, m, c, matrix_a[MAX_MATRIX][MAX_MATRIX], matrix_b[MAX_MATRIX];
        int i,j;

        // initialize matrix_a, matrix_b
        for(i=0; i < MAX_MATRIX; i++)
        {
                for(j=0; j < MAX_MATRIX; j++)
                {
                        matrix_a[i][j] = 0;
                }
                matrix_b[i] = 0;
        }


        //input matrix size
        scanf("%d %d", &n, &m);

        // input matrix_b
        for(i=0; i < n; i++)
        {
                for(j=0; j < m; j++)
                {
                        scanf("%d", &c);
                        matrix_a[i][j] = c;
                }
        }

        // input matrix_b
        for(i=0; i < m; i++)
        {
                scanf("%d", &c);
                matrix_b[i] = c;
        }

        // print output
        for(i=0; i < n; i++)
        {
                c = 0;

                for(j=0; j < m; j++)
                {
                        c += matrix_a[i][j] * matrix_b[j];
                }

                printf("%d\n", c);
        }

        return 0;
}


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

using namespace std;

int main(void) {
	int K, X;
	cin >> K >> X;
	for(int i = X - K + 1; i <= X + K - 1; ++i) {
		cout << i << ' ';
	}
	cout << '\n';
	return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - Trained?

            //コンソールの値を読み込む
            var buttons = ReadLines();

            //ボタンの数字と配列のインデックスが一致するように
            //ボタンの数字をすべて"-1"する
            buttons = buttons.ConvertAll(x => x - 1);

            //"ボタン2"に到達するまでに、ボタンの押された回数をカウント
            int count = CountButtonsPushed(buttons);

            Console.WriteLine(count);
        }

        static int CountButtonsPushed(List<int> buttons)
        {

            //どのボタンがすでに押されたか記録するための配列を作成
            int n = buttons.Count;
            var isPushed = Enumerable.Repeat<bool>(false, n).ToArray();

            //最初に押されるボタンは"1"
            int index = 0;
            int count = 1;

            while (true)
            {
                int buttonNum = buttons[index];

                if (buttonNum == 1)
                {
                    return count;
                }
                else
                {
                    if (isPushed[index])
                    {
                        return -1;
                    }
                    else
                    {
                        isPushed[index] = true;
                        index = buttonNum;
                        count++;
                    }
                }
            }
        }

        static List<int> ReadLines(int count = 0)
        {
            //[summary]コンソールの値を読み込む
            var list = new List<int>();

            //読み込む行数が未指定のときは、1行目の値を"count"とみなす
            if (count == 0)
            {
                string s = Console.ReadLine().TrimEnd();
                count = int.Parse(s);
            }            

            for (int i = 0; i < count; i++)
            {
                string s= Console.ReadLine().TrimEnd();
                list.Add(int.Parse(s));
            }

            return list;
        }
    }
}

Measured memory_bytes: 14816
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i) 
const int N = 1e5 + 5, M = 4e5 + 5 ;
using namespace std ;

int n, m, e, ter[M], nxt[M], lnk[N], opt[N], f[N], cnt[3] ;
bool vis[N] ;

void add(int x, int y) {
	ter[++ e] = y, nxt[e] = lnk[x], lnk[x] = e ;
}

void solve(int x) {
	vis[x] = false ;
	int he = 0, ta = 1 ;
	opt[1] = x, f[x] = 1 ;
	for ( ; he != ta ; ) {
		int u = opt[++ he] ;
		for (int i = lnk[u]; i; i = nxt[i]) {
			f[ter[i]] |= (3 - f[u]) ;
			if (vis[ter[i]]) {
				vis[ter[i]] = false ;
				opt[++ ta] = ter[i] ;
			}
		}
	}
	if (ta == 1) {
		++ cnt[0] ;
		return ;
	}
	rep(i, 1, ta) if (f[opt[i]] == 3) {
		++ cnt[1] ;
		return ;
	}
	++ cnt[2] ;
}

int main() {
	scanf("%d%d", &n, &m) ;
	int x, y ;
	rep(i, 1, m) {
		scanf("%d%d", &x, &y) ;
		add(x, y), add(y, x) ;
	}
	rep(i, 1, n) vis[i] = true ;
	rep(i, 1, n) if (vis[i]) solve(i) ;
	ll ans = (ll) cnt[0] * (n - cnt[0]) * 2 + (ll) cnt[0] * cnt[0] + (ll) cnt[1] * cnt[2] * 2 + (ll) cnt[1] * cnt[1] + (ll) cnt[2] * cnt[2] * 2 ;
	printf("%lld\n", ans) ;
	return 0 ; 
}

Measured memory_bytes: 4608
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e3 + 10;
LL a[N][3];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			cin >> a[i][j];
		}
	}
	LL ans = 0;
	for (int o = 0; o < 8; o++)
	{
		vector<LL> v;
		for (int i = 1; i <= n; i++)
		{
			LL sum = 0;
			for (int j = 0; j < 3; j++)
			{
				if (o >> j & 1) sum += a[i][j];
				else sum -= a[i][j];
			}
			v.push_back(sum);
		}
		sort(v.rbegin(), v.rend());
		LL res = 0;
		for (int i = 0; i < m; i++) res += v[i];
		ans = max(ans, res);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
using namespace std;    

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    bool graph[105][105]={false};
    int num,a,b;
    rep(i,n){
	cin>>a>>b;
	rep(j,b){
	    cin>>num;
	    graph[a][num]=true;
	}
    }
    reps(i,n){
	reps(j,n-1){
	    cout<<graph[i][j]<<" ";
	}
	cout<<graph[i][n]<<'\n';
    }
    
    return 0;
}



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

int main(){
  int n,h,w,kekka = 0;
  cin >> n >> h >> w;
  int a[n],b[n];
  for(int i = 0;i < n;i++){
    cin >> a[i] >> b[i];
  }
  for(int i = 0;i < n;i++){
    if(a[i] >= h && b[i] >= w){
      kekka++;
    }
  }
  cout << kekka << endl;
}

Measured memory_bytes: 256
using System;
class weather{
  public static void Main(){
    String str = Console.ReadLine();
    switch (str){
      case "Sunny":
        Console.WriteLine("Cloudy");
        break;
      case "Cloudy":
        Console.WriteLine("Rainy");
        break;
      case "Rainy":
        Console.WriteLine("Sunny");
        break;
      default:
        break;
    }
  }
}


Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;

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

int calc(string name,map<string,int> data,map<string,vector<string> > recipe)
{
    if (recipe.find(name) != recipe.end())
    {
	int tmp=0;
	rep(i,recipe[name].size())
	{
	    tmp+=calc(recipe[name][i],data,recipe);
	}
	return min(tmp,data[name]);
    } else {
	return data[name];
    }
}

int main()
{
    while(1)
    {
	string name,tmp;
	int price,n,m;
	map<string,int> d;
	map<string,vector<string> > recipe;
	cin >> n;
	if (n==0)break;
	rep(i,n)
	{
	    cin >> name >> price;
	    d[name]=price;
	}
	cin >> m;
	rep(i,m)
	{
	    vector<string> v;
	    cin >> name >> n;
	    rep(j,n)
	    {
		cin >> tmp;
		v.push_back(tmp);
	    }
	    recipe[name] = v;
	}
	cin >> name;
	cout << calc(name,d,recipe) << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N=100005;
int cnt[N];
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  int n,k,q;
  cin>>n>>k>>q;
  rep(i,1,q+1)
    {
      int x;
      cin>>x;
      cnt[x]++;
    }
  rep(i,1,n+1)
    {
      ll tmp=k-q+cnt[i];
      if(tmp<=0) cout<<"No"<<endl;
      else cout<<"Yes"<<endl;
    }
  return 0 ;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MAX_INF 0x3f
#define MAX_INF_VAL 0x3f3f3f3f
#define MAX_INF_VAL_LL 0x3f3f3f3f3f3f3f3f
#define pi 3.141592653589
#define eps 1e-6
//#define p 2173412051LL
//#define sz 2

using namespace std;

int n;
int u, v, lca;
int fa[ 100010 ], dep[ 100010 ], ma[ 100010 ];
vector< int > e[ 100010 ], son[ 100010 ];

void dfs( int );
int check( int );

int main() {
	int n;
	int x, y;
	int ans = 0;
	scanf( "%d%d%d", &n, &u, &v );
	for( int i = 1; i < n; ++i ) {
		scanf( "%d%d", &x, &y );
		e[ x ].push_back( y );
		e[ y ].push_back( x );
	}
	dfs( 1 );
	if( fa[ u ] == v ) {
		printf( "%d", ma[ u ] - dep[ u ] );
		return 0;
	}
	if( fa[ v ] == u ) {
		y = 0;
		while( u ) {
			x = 0;
			for( int i = 0; i < son[ u ].size(); ++i ) {
				if( son[ u ][ i ] == v )
					continue;
				x = max( x, ma[ son[ u ][ i ] ] - dep[ son[ u ][ i ] ] );
			}
			if( x == 0 )
				ans = max( ans, y );
			else
				ans = max( ans, y + 1 + x );
			u = fa[ u ];
			v = fa[ v ];
			++y;
		}
		printf( "%d", ans );
		return 0;
	}
	x = u, y = v;
	while( x != y ) {
		if( dep[ x ] < dep[ y ] )
			swap( x, y );
		x = fa[ x ];
	}
	lca = x;
	if( lca == u ) {
		lca = fa[ v ];
	} else if( lca == v ) {
		x = u;
		while( fa[ x ] != v )
			x = fa[ x ];
		lca = x;
	} else {
		lca = fa[ v ];
	}
	memset( ma, 0, sizeof( ma ) );
	memset( fa, 0, sizeof( fa ) );
	memset( dep, 0, sizeof( dep ) );
	dfs( lca );
	for( int i = u; i; i = fa[ i ] ) {
		x = check( i );
		if( x == -1 )
			break;
		ans = max( ans, x );
	}
	printf( "%d", ans );
	return 0;
}

void dfs( int x ) {
	ma[ x ] = dep[ x ];
	for( int i = 0; i < e[ x ].size(); ++i ) {
		if( e[ x ][ i ] == fa[ x ] )
			continue;
		son[ x ].push_back( e[ x ][ i ] );
		fa[ e[ x ][ i ] ] = x;
		dep[ e[ x ][ i ] ] = dep[ x ] + 1;
		dfs( e[ x ][ i ] );
		ma[ x ] = max( ma[ x ], ma[ e[ x ][ i ] ] );
	}
}

int check( int x ) {
	int res = dep[ u ] - dep[ x ];
	int a = x, b = dep[ u ] + dep[ v ] - dep[ lca ] - 2 * ( dep[ u ] - dep[ x ] );
	if( b <= 0 )
		return -1;
	res += ma[ a ] - dep[ a ];
	while( b ) {
		if( b == 1 )
			break;
		++res;
		b -= 2;
		if( b == 0 )
			break;
		++res;
	}
	return res;
}

Measured memory_bytes: 23560
#include<stdio.h>


int main(){
	int n,a[3];
	scanf("%d",&n);
	int i,j,k;
	for(k=0;k<n;k++){
		scanf("%d %d %d",&a[0],&a[1],&a[2]);
		for(i=0;i<3;i++){
			a[i]=a[i]*a[i];
		}
		j=0;
		for(i=0;i<3;i++){
			if(a[i%3]-a[(i+1)%3]-a[(i+2)%3]==0){
				j=1;
			}
		}
		if(j==1){
			printf("YES\n");
		}else{
			printf("NO\n");
		}

	}
	return 0;
}

Measured memory_bytes: 0
N = int(input())
INF = 10 ** 6
dp = [INF] * (N + 1)

MONEY = []
i = 1
while i <= N:
    MONEY.append(i)
    i *= 6
i = 1
while i <= N:
    MONEY.append(i)
    i *= 9

MONEY.sort()
# print(MONEY)

for init in MONEY:
    dp[init] = 1


for i in range(1, N + 1):
    for plus in MONEY:
        if i + plus <= N:
            dp[i + plus] = min(dp[i] + 1, dp[i + plus])
# print(dp)
print(dp[N])





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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1e18;
#define int long long
#define pii pll

struct edge{
    int to;
    int cost;

    edge(int x, int y) : to(x), cost(y) { }
};

using Graph = vector<vector<edge>>;

void dijkstra(const Graph &G, int s, int v, int* d){
    priority_queue<pii, vector<pii>, greater<pii>> que;
    fill(d, d+v, INF);
    d[s] = 0;
    que.push(pii(0, s));

    while(!que.empty()){
        pii p = que.top();
        que.pop();
        int nv = p.second;
        if(d[nv] < p.first) continue;

        for (int i = 0; i < G[nv].size(); ++i) {
            edge e = G[nv][i];
            if(d[e.to] > d[nv] + e.cost){
                d[e.to] = d[nv] + e.cost;
                que.push(pii(d[e.to], e.to));
            }
        }
    }
}

int dyen[100010];
int dsno[100010];

signed main(){
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    s--; t--;

    Graph yen(n), sno(n);

    int u, v, a, b;
    for (int i = 0; i < m; ++i) {
        cin >> u >> v >> a >> b;
        u--; v--;
        yen[u].emplace_back(edge{v, a});
        yen[v].emplace_back(edge{u, a});
        sno[u].emplace_back(edge{v, b});
        sno[v].emplace_back(edge{u, b});
    }

    dijkstra(yen, s, n, dyen);
    dijkstra(sno, t, n, dsno);

    vector<pll> res;
    for (int i = 0; i < n; ++i) {
        res.emplace_back(pll(dyen[i] + dsno[i], i));
    }

    sort(res.begin(), res.end());

    int index = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = index; j < res.size(); ++j) {
            if(res[j].second >= i){
                cout << 1000000000000000 - res[j].first << endl;
                break;
            }else{
                index++;
            }
        }
    }
}

Measured memory_bytes: 19836
#include<cstdio>
#include<algorithm> 
#include<cstring>
#include<cstdlib>
#define LL long long
using namespace std;
int n,a,b,x;
int read()
{
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	return x*f;
}
int main()
{
	n=read();a=read();b=read();
	x=abs(a-b);
	if(x&1)printf("Borys");
	else printf("Alice");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
const long long MOD = 1000000007;
const int INF = INT_MAX / 2;
const long double PI = 3.1415926;
using namespace std;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> vp;
typedef vector<tuple<ll, ll, ll>> vt;

//vector<vector<ll>> vv(n, vector<ll>(n));

typedef int Weight;
struct Edge
{
	int from, to; Weight cost;
	bool operator < (const Edge& e) const { return cost < e.cost; }
	bool operator > (const Edge& e) const { return cost > e.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void add_edge(Graph &g, int from, int to, Weight cost)
{
	g[from].push_back(Edge{ from, to, cost });
}


int main()
{
	ll n;
	cin >> n;
	REP(i,100000)
	{
		if(i*(i+1)/2>=n)
		{
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define ll int64_t
#define _GLIBCXX_DEBUG
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
//約数列挙(√N)
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}
//素因数分解(√N)
map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}
//素数テーブル(NloglogN)
vector< bool > prime_table(int n) {
  vector< bool > prime(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}
//二項係数(K)
template< typename T >
T binomial(int64_t N, int64_t K) {
  if(K < 0 || N < K) return 0;
  T ret = 1;
  for(T i = 1; i <= K; ++i) {
    ret *= N--;
    ret /= i;
  }
  return ret;
}
//二項係数テーブル(N^2)
template< typename T >
vector< vector< T > > binomial_table(int N) {
  vector< vector< T > > mat(N + 1, vector< T >(N + 1));
  for(int i = 0; i <= N; i++) {
    for(int j = 0; j <= i; j++) {
      if(j == 0 || j == i) mat[i][j] = 1;
      else mat[i][j] = mat[i - 1][j - 1] + mat[i - 1][j];
    }
  }
  return mat;
}
int main(){
  int a;
  cin >> a;
  cout << a+a*a+a*a*a << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  char c[N];
  int K;
  cin >> N;
  cin >> c;
  cin >> K;
    for(int i = 0;i<N;i++){
      if(c[K - 1] == c[i]){
        cout << c[K - 1];
      }
      else{
        cout << "*";
      }
    }
  cout << endl;
}


Measured memory_bytes: 256
//shan61916
#include <bits/stdc++.h>
    using namespace std;
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n" 
typedef long long ll;
typedef unsigned long long ull ;
typedef double dll ;
ll n, w;
vector<ll> a, v;
ll dp[110][100010];
ll recurse(ll idx, ll wt) {
	// cout << idx << wt << endl;
	if(idx >= n) return 0;
	if(dp[idx][wt] != -1) return dp[idx][wt];
	dp[idx][wt] = 0;
	if(a[idx] + wt <= w) {
		dp[idx][wt] = v[idx] + recurse(idx+1, wt+ a[idx]);
	}
    return dp[idx][wt] = max({dp[idx][wt], recurse(idx+1, wt)}) ;
}
int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  cin >> n >> w;
  memset(dp, -1, sizeof(dp));
  a.resize(n), v.resize(n);
  for(ll i = 0; i < n; i++) {
  	cin >> a[i];
  	cin >> v[i];
  }
  ll ans = recurse(0, 0);
  cout << ans;

  return 0;
} //good night.

Measured memory_bytes: 86272
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#define IL inline
#define RG
#define db double
#define pi acos(-1.0)
#define inf 0x3f3f3f3f
#define LL long long
using namespace std;
IL int gi()
{
    RG int res=0,s=1;RG char ch;
    for(ch=getchar(); (ch<'0'||ch>'9')&&ch!='-' ;ch=getchar());
    if(ch=='-') s=-1,ch=getchar();
    for(;ch>='0'&&ch<='9';ch=getchar()) res=10*res+ch-48;
    return res*s;
}
int n,a[100005];
IL int check1(RG LL x) {
	for(RG int i=1;i<=n;++i)
		x=1ll*(x/a[i])*a[i];
	return x<=1ll*2;
}
IL int check2(RG LL x) {
	for(RG int i=1;i<=n;++i)
		x=1ll*(x/a[i])*a[i];
	return x>=1ll*2;
}
int main()
{
	n=gi(); RG LL a1,a2;
	for(RG int i=1;i<=n;++i) a[i]=gi();
	RG LL l=0,r=1e18,mid;
	while(l<r) {
		mid=(l+r)>>1;
		if(check2(mid)) r=mid;
		else l=mid+1;
	}
	a1=l;
	l=0,r=1e18;
	while(l<r) {
		mid=(l+r)>>1; mid++;
		if(check1(mid)) l=mid;
		else r=mid-1;
	}
	a2=l;
	if(a1>a2) printf("-1\n");
	else printf("%lld %lld\n",a1,a2);
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int next_permutation(int *A, int size)
{
    if (size == 1) return 0;

    int i, flag = 0;
    for (i = size - 2; i >= 0; i--) {
        if (A[i] < A[i+1]) {
            flag = 1;
            break;
        }
    }
    
    if (flag == 0) return 0;

    int j, tmp;
    for (j = size - 1; j > i; j--) {
        if (A[j] > A[i]) {
            tmp = A[j];
            A[j] = A[i];
            A[i] = tmp;
            break;
        }
    }
    int mid = (size - i - 1) / 2;
    for (j = 1; j <= mid; j++) {
        tmp = A[i+j];
        A[i+j] = A[size-j];
        A[size-j] = tmp;
    }
    return 1;
}

void print_array(int *A, int size)
{
    int i;
    printf("%d", A[0]);
    for (i = 1; i < size; i++) printf(" %d", A[i]);
    putchar('\n');
}

int main(void)
{
    int n;
    scanf("%d", &n);

    int A[9];
    int i;
    for (i = 0; i < n; i++) A[i] = i + 1;

    do {
        print_array(A, n);
    } while (next_permutation(A, n));

    return 0;
}


Measured memory_bytes: 2144
import java.util.Scanner;

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

			for(;;) {
				int a = sc.nextInt();
				String op = sc.next();
				int b = sc.nextInt();

				if(op.equals("+")) {
					System.out.println(a + b);
				}
				if(op.equals("-")) {
					System.out.println(a - b);
				}
				if(op.equals("*")) {
					System.out.println(a * b);
				}
				if(op.equals("/")) {
					System.out.println(a / b);
				}
				if(op.equals("?")) {
					break;
				}
			}
	}
}

Measured memory_bytes: 26160
import sys

_input1 = int(input())
_input2 = [int(s) for s in input().split()]
_output = sys.maxsize

for i in range(min(_input2),max(_input2)+1):
    score = 0
    for j in _input2:
        score += (j-i)**2

    if score < _output:
        _output = score

print(_output)

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

int main() {
	string A;
  	cin >> A;
  	string B;
  	cin >> B;
  
  	if(A.at(0) == B.at(2) && A.at(1) == B.at(1) && A.at(2) == B.at(0))cout << "YES" << endl;
  	else cout << "NO" << endl;
}


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

inline bool is_right_triangle(int a, int b, int c){
	return (a*a == b*b + c*c || b*b == a*a + c*c || c*c == a*a + b*b) ? true : false;
}


int main() {
	ios::sync_with_stdio(false);
	int n, a, b, c;
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> a >> b >> c;
		if(is_right_triangle(a,b,c)) cout << "YES" << "\n";
		else cout << "NO" << "\n";
	}

}

Measured memory_bytes: 1172
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    cin >> a >> b;
    
    if(a>0){
        cout << "Positive" << endl;
    }
    
    if((a<=0) && (b>=0)){
        cout << "Zero" << endl;
        return 0;
    }
    
    if(b<0){
        if((b-a+1)%2){
            cout << "Negative" << endl;
            return 0;
        }else {
            cout << "Positive" << endl;
            return 0;
        }
    }
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int Alice_score,Bob_score;
  
  vector<int> A(N + 100);
  for (int i; i < N; i++) cin >> A.at(i);
  
  sort(A.begin(), A.end(), greater<int>());
  
  for (int i; i < N; i++) {
    if (i % 2 == 0) Alice_score += A.at(i);
    else Bob_score += A.at(i);
  }
  
  cout << Alice_score - Bob_score << endl;
}

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;

int main(){
  string s;
  cin >> s;
  if(s[2] == s[3]&& s[4]==s[5]) puts("Yes");
  else puts("No");
  cout << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
from bisect import bisect_left,bisect_right
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    X=int(input())
    l=[i**5 for i in range(2000)]
    for i,a in enumerate(l):
        for j,b in enumerate(l):
            if a-b==X:
                print(i,j)
                exit()
            elif a+b==X:
                print(i,-j)
                exit()
    raise Exception
    

if __name__ == '__main__':
    main()


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

long long ans,d;
int main() {
	
	long long n,n1;
	cin >> n;
	n1 = n;
	long long k = 2;
	while (n > 1) {
	
		while (n % k == 0) { n /= k; ++d; }

		
		for (int i = 1; d-i >= 0; ++i) {
			ans++;
			d -= i;
		}
			
		
		 d = 0;
		
    
		
		if(k < int(sqrt(n1))) ++k;
		else k = n; 
		
	
			
		}
		
	cout << ans;
		
		
}

Measured memory_bytes: 3680
#include<bits/stdc++.h>
#define inf 1e18
#define N 100005
#define ll long long int
#define pb push_back
int dp[N]={0};
bool vis[N]={false};
using namespace std;
void dfs(int x,vector<int>adj[]){
	vis[x]=true;
	for(auto u:adj[x]){
		if(vis[u]==false)
		dfs(u,adj);
		dp[x]=max(dp[x],dp[u]+1);
	}
}
int main(void){
	int n,m,ans=0,i,a,b;
	cin>>n>>m;
	vector<int>adj[n+1];
	//map<int,int>parent;
	for(i=0;i<m;i++){
		cin>>a>>b;
		adj[a].pb(b);
	}
	for(i=1;i<=n;i++){
		if(vis[i]==false)
		dfs(i,adj);
	}
	for(i=1;i<N;i++)
	ans=max(ans,dp[i]);
	cout<<ans;
	
}


Measured memory_bytes: 8192
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)


def main():
    N, Q = map(int, input().split())

    uni = UnionFind(N)
    for i in range(Q):
        t, u, v = map(int, input().split())
        if t == 0:
            uni.unite(u, v)
        else:
            if uni.same(u, v):
                print(1)
            else:
                print(0)


main()


Measured memory_bytes: 93844
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

int main() {
  int b, r, g, c, s, t;
  while(cin >>b >>r >>g >>c >>s >>t && (b || r || g || c || s || t)){
    int sum = 100;
    sum += b * 15;
    sum += r * 15;
    sum += g * 7;
    sum += c * 2;
    sum += (b * 5 + r * 3) * 13;
    sum -= (t - b * 5 - r * 3 - s) * 3;
    cout <<sum <<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

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

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			scanner.nextInt();
			System.out.println(
					IntStream.range(0, n).mapToObj(i -> scanner.next()).sorted().collect(Collectors.joining()));
		}
	}
}


Measured memory_bytes: 28372
from collections import Counter,defaultdict,deque
import sys,bisect,math,itertools,string,queue
from heapq import heappop, heappush
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

def check(S): #Sが単一の文字かどうか
    n = len(S)
    for i in range(n-1):
        if S[i] != S[i+1]:
            return False
    return True
S = input()
n = len(S)
T = S
res = float('inf')
for i in range(97,97+26+1):
    S = T
    if not chr(i) in S:
        continue
    # print(chr(i))
    cnt = 0
    while True:
        if check(S):
            break
        tmp = ''
        for j in range(len(S)-1):
            if S[j] == chr(i) or S[j+1] == chr(i):
                tmp += chr(i)
            else:
                tmp += S[j]
        S = tmp
        cnt += 1
    res = min(res, cnt)
    
print(res)


Measured memory_bytes: 42712
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define push push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
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 INFLL = 1LL<<62;
const int INF = 1<<30;
int main(){
    int n;
    int ans=INF*-1;
    int bef=0;
    cin >>n;
    vector<vector<int>>f(n,vector<int>(11,0));
    vector<int>fb(n,0);
    vector<vector<int>>p(n,vector<int>(13,0));
    vector<int>crb(n,0);
    rep(i,n){
        rep(j,10){
            cin>>f[i][j];
            fb[i]|=((f[i][j])<<j);
        }
     //   cout<<fb[i]<<endl;
    }
    rep(i, n)
    {
        rep(j, 11)
        {
            cin >> p[i][j];
          
        }
        //   cout<<fb[i]<<endl;
    }
    for(int bit=1;bit<(1<<10);bit++){
        bef=0;
        rep(i,n){
            crb[i]=(bit&fb[i]);
            bef+=p[i][__builtin_popcount(crb[i])];
        }
      //  cout<<bef<<" "<<bit<<endl;
        chmax(ans,bef);
    }
    cout<<ans<<endl;
}

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

typedef struct{
  int A[1000];
  int ans;
  bool c;
}node;
node T[1000];
int Q[10000000];
int head=0;
int tail=1;
int n;

void function(int num){
  while(true){
    if(head==tail)break;
    num=Q[head++];
    T[num].c=true;
    for(int i=2;i<=n;i++){
      if(T[num].A[i]==1&&T[i].c==false){
	if(T[i].ans==0){
	  T[i].ans=T[num].ans+1;
	  T[num].A[i]=0;
	}
	Q[tail++]=i;
      }
    }
    //    cout<<"Q "<<Q[head]<<endl;
    //  cout<<head<<" "<<tail<<endl;
  }

}

int main(){
  int num;
  int son;
  int z;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>num;
    cin>>son;
    for(int j=0;j<son;j++){
      cin>>z;
      T[num].A[z]=1;
      }
  }
  Q[0]=1;
  function(1);
  T[1].ans=0;
  for(int i=2;i<=n;i++){
    if(T[i].ans==0){
      T[i].ans=-1;
    }
  }

  for(int i=1;i<=n;i++){
      cout<<i<<" "<<T[i].ans<<endl;
  }


  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int main(){
	int r,D,x,i;
	scanf("%d %d %d",&r,&D,&x);
	for(i = 1;i <=10;i++){
		printf("%d\n",r * x - D);
		x = r * x - D;
	}
	return 0;
}

Measured memory_bytes: 1732
n, m, c = map(int,input().split())
b = list(map(int,input().split()))
a = [0 for i in range(n)]
sum = 0
count = 0
for i in range(n):
    a[i] = list(map(int,input().split()))
for i in range(n):
    for j in range(m):
        sum += a[i][j] * b[j]
    sum += c
    if sum > 0:
        count += 1
    sum = 0
print(count)



Measured memory_bytes: 3064
#include <cstdio>
#include <vector>
#include <algorithm>

int main() {
  size_t N;
  scanf("%zu", &N);

  std::vector<int> a(N);
  for (auto& ai: a) {
    int i, p;
    scanf("%d.%d", &i, &p);
    ai = 1000*i + p;
  }

  std::vector<int> b = a;
  std::sort(b.begin(), b.end());

  for (auto ai: a) {
    auto lb = std::lower_bound(b.begin(), b.end(), ai);
    auto ub = std::upper_bound(b.begin(), b.end(), ai);

    int draw = (ub-lb) - 1;
    int win = (lb-b.begin());
    printf("%d\n", draw+3*win);
  }
}



Measured memory_bytes: 3220
#include <cstdio>
#include <iostream>
#include <bitset>
#include <queue>
#include <utility>

using namespace std;
typedef long long ll;

int main(){
    int x,y;
    cin >> x >> y;
    if(x%y!=0) cout << x << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
/*************************************************************************
> File Name: test.cpp
> Author: Akira 
> Mail: qaq.febr2.qaq@gmail.com 
************************************************************************/

#include<bits/stdc++.h>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
#define MST(a,b) memset(a,b,sizeof(a))
#define CLR(a) MST(a,0)
#define Sqr(a) ((a)*(a))
#define ALL(a) a.begin(), a.end()
#define mp make_pair
#define pb push_back
using namespace std;

#define MaxN 100005
#define MaxM MaxN*10
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626
const int mod = 1E9+7;
const double eps = 1e-6;
#define bug cout<<88888888<<endl;
#define debug(x) cout << #x" = " << x << endl;
template<typename T> T abs(T val){return val>0?val:-val;}
inline int max2(int a, int b) {return ((a > b)? a : b);}
inline int min2(int a, int b) {return ((a < b)? a : b);}
inline int max3(int a, int b, int c) {return max2(a, max2(b, c));}
inline int min3(int a, int b, int c) {return min2(a, min2(b, c));}
template <class T> inline void read(T &ret) {char c; ret=0;while((c=getchar())<'0'||c>'9');while(c>='0'&&c<='9') ret=ret*10+(c-'0'),c=getchar();}
template <class T> inline void out(T x) {if(x>9) out(x/10);putchar(x%10+'0');}

int N,A[MaxN];
map<int,int> M;

void solve()
{
    M.clear();
    int mx = -1, mxx = -1;
    for(int i=1;i<=N;i++) 
    {
        M[A[i]]++;
        if(M[A[i]] == 2)
        {
            if(A[i]>mx) 
            {
                mxx = mx;
                mx = A[i];
                M[A[i]] = 0;
            }
            else if(A[i]>mxx)
            {
                mxx = A[i];
                M[A[i]] = 0;
            }
        }
    }
    // debug(mx) debug(mxx)
    if(mx>0 && mxx>0) 
    {
        LL ans = 1LL*mx*mxx;
        out(ans);puts("");
    }
    else puts("0");
}
int main()
{
    //std::ios::sync_with_stdio(false);
    while(~scanf("%d", &N))
    { 
        for(int i=1;i<=N;i++) read(A[i]);
        solve();
    }
    //system("pause");
    //printf("%lld\n", ((x)%mod+mod)%mod );
    //printf("\n%.2lf sec \n", (double)clock() / CLOCKS_PER_SEC);
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    if(n & 1){
    	cout << 0 << endl;
    }else{
    	n /= 2LL;
    	ll ans = 0;
    	while(n >= 5LL){
    		n /= 5LL;
    		ans += n;
    	}
    	cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const long long INF = (long long) 1e18;
const int mod = (int) 1e9+7;
const int MAXN = (int) 1e6+5;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
string n;
int dp[MAXN][2];
ll do_it(int ind, int dur){
    if(ind == n.length()) return dur;
    if(dp[ind][dur] != -1){
        return dp[ind][dur];
    }

    if(dur){
        if(n[ind] == '9'){
            return dp[ind][dur] = do_it(ind + 1, dur);
        }else{
            return dp[ind][dur] = min(n[ind] - '0' + 1 + do_it(ind + 1, 0), 10 - (n[ind] - '0' + 1) + do_it(ind + 1, 1));
        }
    }else{
        return dp[ind][dur] = min(n[ind] - '0' + do_it(ind + 1, 0), 10 - (n[ind] - '0') + do_it(ind + 1, 1));
    }

}


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

    #ifdef Local
        freopen("../IO/int.txt","r",stdin);
        freopen("../IO/out.txt","w",stdout);
    #endif

    memset(dp, - 1, sizeof(dp));
    cin>>n;
    reverse(n.begin(), n.end());
    cout<<do_it(0, 0);

    #ifdef Local
        cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}

Measured memory_bytes: 56092
def kiriage(price):
    i = int(price) / 1000
    r = price % 1000
    if r != 0:
        return 1000 * (i + 1)
    else:
        return 1000 * i

if __name__ == '__main__':
    n = int(raw_input())
    price = 100000
    for i in range(0, n):
        price = kiriage(price * 1.05)
    print price

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

struct SuffixArray {
  vector< int > SA;
  const vector<int> s;

  SuffixArray(const vector<int> &str) : s(str) {
    SA.resize(s.size());
    iota(begin(SA), end(SA), 0);
    sort(begin(SA), end(SA), [&](int a, int b) {
      return s[a] == s[b] ? a > b : s[a] < s[b];
    });
    vector< int > classes(s.size()), c(s.begin(), s.end()), cnt(s.size());
    for(int len = 1; len < s.size(); len <<= 1) {
      for(int i = 0; i < s.size(); i++) {
        if(i > 0 && c[SA[i - 1]] == c[SA[i]] && SA[i - 1] + len < s.size() && c[SA[i - 1] + len / 2] == c[SA[i] + len / 2]) {
          classes[SA[i]] = classes[SA[i - 1]];
        } else {
          classes[SA[i]] = i;
        }
      }
      iota(begin(cnt), end(cnt), 0);
      copy(begin(SA), end(SA), begin(c));
      for(int i = 0; i < s.size(); i++) {
        int s1 = c[i] - len;
        if(s1 >= 0) SA[cnt[classes[s1]]++] = s1;
      }
      classes.swap(c);
    }
  }

  int operator[](int k) const {
    return SA[k];
  }

  size_t size() const {
    return s.size();
  }

  bool lt_substr(const vector<int> &t, int si = 0, int ti = 0) {
    int sn = (int) s.size(), tn = (int) t.size();
    while(si < sn && ti < tn) {
      if(s[si] < t[ti]) return true;
      if(s[si] > t[ti]) return false;
      ++si, ++ti;
    }
    return si >= sn && ti < tn;
  }

  int lower_bound(const vector<int> &t) {
    int low = -1, high = (int) SA.size();
    while(high - low > 1) {
      int mid = (low + high) / 2;
      if(lt_substr(t, SA[mid])) low = mid;
      else high = mid;
    }
    return high;
  }

  pair< int, int > lower_upper_bound(vector<int> &t) {
    int idx = lower_bound(t);
    int low = idx - 1, high = (int) SA.size();
    t.back()++;
    while(high - low > 1) {
      int mid = (low + high) / 2;
      if(lt_substr(t, SA[mid])) low = mid;
      else high = mid;
    }
    t.back()--;
    return {idx, high};
  }
};

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vi a(n),b(n);
    rep(i,n) cin>>a[i];
    rep(i,n) cin>>b[i];
    vi S(2*n-1), T(n);
    rep(i,2*n-1) S[i] = a[i%n]^a[(i+1)%n];
    rep(i,n) T[i] = b[i%n]^b[(i+1)%n];
    SuffixArray sa(S);
    auto range = sa.lower_upper_bound(T);
    vector<pi> ans;
    FOR(i, range.fi, range.se-1){
        int shift = sa[i];
        int x = b[0]^a[shift];
        ans.emplace_back(shift,x);
    }
    sort(all(ans));
    for(auto e:ans){
        cout<<e.fi<<" "<<e.se<<"\n";
    }
    return 0;
}


Measured memory_bytes: 14124
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

const int nax = 3005;
ll dp[nax][nax];

int main() {
    int n;
    scanf("%d", &n);
    vector<int> a(n);
    for(int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
    }
    // dp[0][n-1]
    for(int L = n - 1; L >= 0; --L) {
        for(int R = L; R < n; ++R) {
            if(L == R) {
                dp[L][R] = a[L];
            }
            else {
                dp[L][R] = max(a[L] - dp[L+1][R], a[R] - dp[L][R-1]);
            }
        }
    }
    printf("%lld\n", dp[0][n-1]);
}

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

int main(){
	int a, b;
  	cin>>a>>b;
  	
  	int c=1;
  	if(a==c||b==c){
    	c=2;
    }
  	if(a==c||b==c){
    	c=3;
    }
	cout<<c<<endl;
}

Measured memory_bytes: 256
// C++ code to count the number of 
// possible triangles using brute 
// force approach 
#include <bits/stdc++.h> 
using namespace std; 

// Function to count all possible 
// triangles with arr[] elements 
int findNumberOfTriangles(long long int arr[], int n) 
{ 
	// Count of triangles 
	int count = 0; 

	// The three loops select three 
	// different values from array 
	for (int i = 0; i < n; i++) { 
		for (int j = i + 1; j < n; j++) { 

			// The innermost loop checks for 
			// the triangle property 
			for (int k = j + 1; k < n; k++) 
                    if((arr[i]!=arr[j])&&(arr[i]!=arr[k])&&(arr[j]!=arr[k]))
                    {
				// Sum of two sides is greater 
				// than the third 
				if ( 
					arr[i] + arr[j] > arr[k] 
					&& arr[i] + arr[k] > arr[j] 
					&& arr[k] + arr[j] > arr[i]) 
                {count++;}
                    } 
		} 
	} 
	return count; 
} 

// Driver code 
int main() 
{ 
	int n;
	cin>>n;
	long long int arr[n];
	for(int i=0;i<n;i++)
	{cin>>arr[i];}
	int size = sizeof(arr) / sizeof(arr[0]); 

	cout<< findNumberOfTriangles(arr, size)<<"\n"; 

	return 0; 
} 

Measured memory_bytes: 3632
#pragma warning(disable: 4996)

#include <iostream>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <functional>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <vector>
#include <bitset>
#include <numeric>
#include <string>
#include <set>
#include <tuple>
#include <utility>
#include <regex>
#include <deque>
#include <map>
#include <queue>
using namespace std;

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	char c;
	cin >> c;
	cout << char(c + 1);
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<vector<int>> v(100005);
    rep(i,n){
        int a, b;
        cin >> a >> b;
        v[a].push_back(b);
    }
    ll ans = 0;
    priority_queue<int> pq;
    for(int i = 1; i <= m; ++i){
        for(int x : v[i]) pq.push(x);
        if(pq.empty()) continue;
        ans += pq.top();
        pq.pop();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5632
import java.util.Scanner;

public class Main{

	static final Scanner	s	=new Scanner(System.in);

	public static void main(String args[]){
		input();
		solve();
	}

	private static void input(){
	}

	private static void solve(){
		System.out.println(s.nextInt()<1200?"ABC":"ARC");
	}
}


Measured memory_bytes: 21844
#include <iostream>

using namespace std;

const int MAX_N = 23;

struct Ant {
    int  num, p;
    char d;
    Ant() { p = -1; }
};

int n, l;
Ant even[MAX_N], odd[MAX_N];
int num_odd, num_even;

void Input()
{
    int  p;
    char d;

    num_odd = num_even = 0;
    for (int i = 0; i < n; i++) {
        cin >> d >> p;

        if (p % 2 == 0) {       // 偶数番目のあり
            if (d == 'L')
                even[num_even].p = p;
            else
                even[num_even].p = l - p;

            even[num_even].num = i + 1;
            even[num_even++].d = d;
        }
        else {                  // 奇数番目のあり
            if (d == 'L')
                odd[num_odd].p = p;
            else
                odd[num_odd].p = l - p;

            odd[num_odd].num = i + 1;
            odd[num_odd++].d = d;
        }
    }
}

Ant Solve(const Ant ant[MAX_N], const int &num)
{
    Ant res;                    // antにおける最後に落ちるあり

    if (num <= 0)
        return res;

    int left_num = 0, right_num = 0; // 左向きの数，右向きの数
    Ant right, left;            // 一番左にいる右向きのあり，一番右にいる左向きのあり

    // 左向き，右向きの数のカウント
    for (int i = 0; i < num; i++) {
        if (ant[i].d == 'L')
            left_num++;
        else
            right_num++;
    }

    // 一番左にいる右向きのありの探索
    for (int i = 0; i < num; i++)
        if (ant[i].d == 'R') {
            right = ant[i];
            break;
        }
    // １番右にいる左向きのありの探索
    for (int i = num - 1; i >= 0; i--)
        if (ant[i].d == 'L') {
            left = ant[i];
            break;
        }

    // rightとleftの比較
    if (left.p >= right.p) {
        res.p   = left.p;
        res.num = ant[left_num - 1].num;
        res.d   = 'L';
    }
    else {
        res.p   = right.p;
        res.num = ant[num - right_num].num;
        res.d   = 'R';
    }

    return res;
}

int main()
{
    while (cin >> n >> l, n || l) {
        Input();
        Ant ant_e = Solve(even, num_even);
        Ant ant_o = Solve(odd, num_odd);

        if (ant_e.p == ant_o.p) {
            if (ant_e.d == 'L')
                cout << ant_e.p << " " << ant_e.num << endl;
            else
                cout << ant_o.p << " " << ant_o.num << endl;
        }
        else if (ant_e.p > ant_o.p)
            cout << ant_e.p << " " << ant_e.num << endl;
        else
            cout << ant_o.p << " " << ant_o.num << endl;
    }

    return 0;
}

Measured memory_bytes: 1168
using System;

namespace ABC109_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] array = Console.ReadLine().Split(' ');
            int a = int.Parse(array[0]);
            int b = int.Parse(array[1]);
            if(a * b % 2 == 1)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
// using namespace atcoder;
void Main()
{
    ll n;
    cin >> n;

    ll mod = 7LL + 1e9;
    ll pow10 = 1, pow9= 1, pow8 = 1;
    rep(i, n) {
        pow10 *= 10;
        pow10 %= mod;
        pow8 *= 8;
        pow8 %= mod;
        pow9 *= 9;
        pow9 %= mod;
    }

    ll res = ((2 * pow9 % mod) - pow8) % mod;
    res = (pow10 + mod - res) % mod;
    put(res);
}
signed main(){ Main();return 0;}

Measured memory_bytes: 3628