akhauriyash/Code-Regression huggingface dataset:
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from math import sqrt
from heapq import heappush, heappop

# node class
class Node(object):
    def __init__(self, num, x, y, r):
        self.num = num
        self.x = x
        self.y = y
        self.r = r
        
# graph class
class Graph(object):
    def __init__(self, num):
        self.graph = [[] for _ in range(num)]
        self.nodes = []
        
    # 辺の長さを調べる
    def calc_edge_len(self, node1, node2):
        dist = sqrt((node1.x - node2.x)**2 + (node1.y - node2.y)**2) - node1.r - node2.r
        if dist <= 0:
            return 0
        else:
            return dist
        
    # 辺を追加する
    def add_edge(self, node1, node2):
        edge_len = self.calc_edge_len(node1, node2)
        self.graph[node1.num].append((edge_len, node2.num))
        self.graph[node2.num].append((edge_len, node1.num))
    
    def get_graph(self):
        return self.graph

# ダイクストラ法
def dijkstra(graph:list, node:int, start:int, goal:int) -> int:
    # 未探索のノードは距離INF
    INF = float("inf")
    dist = [INF]*node
    
    # 始点ノードの距離を0とし、dfsのためのpriority queを作成
    dist[start] = 0
    heap = [(0,start)]
    visited = [False]*node
    
    # 未探索のノードをpriority queueに入れる
    while heap:
        cost, cur_node = heappop(heap)
        
        if visited[cur_node]:
            continue
        
        visited[cur_node] = True
        
        if cur_node == goal:
            return dist[goal]
        
        
        for nex_cost, nex_node in graph[cur_node]:
            dist_cand = dist[cur_node] + nex_cost
            if dist_cand < dist[nex_node]:
                dist[nex_node] = dist_cand
                heappush(heap, (dist[nex_node], nex_node))
    
    return dist[goal]

# input
xs, ys, xt, yt = li()
n = ni()

# グラフにスタートとゴールを追加
g = Graph(n+2)
g.nodes.append(Node(0,xs,ys,0))
g.nodes.append(Node(1,xt,yt,0))

# グラフにそれぞれのバリアを追加
for i in range(n):
    x,y,r = li()
    g.nodes.append(Node(i+2,x,y,r))

# バリアを結ぶエッジを追加していく
for i in range(len(g.nodes)):
    for j in range(i+1, len(g.nodes)):
        g.add_edge(g.nodes[i], g.nodes[j])
        
graph = g.get_graph()

# 隣接リストをダイクストラに放り込む
dist = dijkstra(graph, n+2, 0,1)

print(dist)


Measured memory_bytes: 124380
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#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 eb emplace_back

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

int n, m, q;
vi a, b, c, d;
vi A;
ll mx = 0;

void dfs(int depth = 0, int parnum = 1){
    if(depth == n) {
        ll tot = 0;
        rep(i,q){
            if(A[b[i]] - A[a[i]] == c[i]) tot += d[i];
        }
        mx = max(mx, tot);
    }
    else{
        rep3(i, parnum, m){
            A[depth] = i;
            dfs(depth + 1, i);
        }
    }     
}

void Main(){
    cin >> n >> m >> q;
    a.resize(q);
    b.resize(q);
    c.resize(q);
    d.resize(q);
    A.resize(n);
    
    rep(i,q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--; b[i]--;
    }
    dfs();
    cout << mx << endl;
	return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 3612
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PI 3.14159265358979323846264338327950L
#define MOD 1000000007
#define sz 100005
ll inf = 1e18;
ll power(ll x, ll n, ll mod)
{
  ll res = 1;
  x %= mod;
  while (n)
  {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res%mod;
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif
  bool x;
  cin>>x;
  cout<<!x;
  return 0;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define ll long long int
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(a) (a).begin(), (a).end()
#define OUT(x) out << (x) << endl;
#define M0(x) memset(x, 0, sizeof(x))
#define MINF(x) memset(x, 0x3f, sizeof(x))
#define MMINUS(a) memset(a, 0xff, sizeof(a))
#define ten(n) ((int)1e##n)

const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
const double EPS = 1.0 / INF;
const char ENDL = '\n'; // for JetBrains IDE only supports yen

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

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

using namespace std;

//===================================== template =========================================================

int main() {
    cin.tie(nullptr); ios_base::sync_with_stdio(false);
    int N, X; cin >> N >> X;
    vector<int> sub(N); REP(i, N) { int tmp; cin >> tmp; sub[i] = abs(tmp-X); }
    int ans = sub[0];
    REP(i, N-1) ans = gcd(ans, sub[i+1]);
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <stdio.h>

long long length[50],paty[50];

long long f(int N,long long X){
  if(N == 0){
    if(X <= 0) return 0;
    else return 1;
  }
  if(X <= 0) return 0;
  else if(X <= 1+length[N-1]) return f(N-1,X-1);
  else return paty[N-1]+1+f(N-1,X-2-length[N-1]);
}

int main(void){
  int N;
  long long X;

  scanf("%d%lld",&N,&X);

  length[0] = 1; paty[0] = 1;
  for(int i = 1;i < N;i++){
    length[i] = 3+2*length[i-1];
    paty[i] = 1+2*paty[i-1];
  }

  printf("%lld\n",f(N,X));
  return 0;
}

Measured memory_bytes: 128
while True:
    buff = input()
    n, x = map(int, buff.split())
    
    if n == 0 and x == 0:
        break
    
    l = 0
    for i in range(1, n+1):
        for j in range(i+1, n+1):
            for k in range(j+1, n+1):
                if i + j + k == x:
                    l += 1
    
    print(l)


Measured memory_bytes: 5596
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);i++)
#define urep(i,a,n) for(ll i = (a);i>=(n);i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
ll ans;
string S;
ll N;
ll T[101];
ll p[100001];

int main() {
	cin >> N;
	rep(i, 1, N+1) {
		cin >> p[i];
	}
	ans = 0;
	if (p[1] == 1) {
		swap(p[1], p[2]);
		ans++;
	}
	rep(i, 2, N+1) {
		if (p[i] == i) {
			if (i == N)ans++;
			else {
				if (p[i + 1] != i)
					swap(p[i + 1], p[i]);
				else
					swap(p[i - 1], p[i]);
				ans++;
			}
		}
	}
	cout << ans << endl;
	cin >> ans;
	return 0;
}

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

using ll = long long int;
using P = pair<ll, ll>;
using P3 = pair<int, P>;
using PP = pair<P, P>;
constexpr int INF = 1 << 30;
constexpr ll MOD = ll(1e9) + 7;
constexpr int di[] = {0, 1, 0, -1};
constexpr int dj[] = {1, 0, -1, 0};


int main() {
    int n;
    cin >> n;
    vector<P> v(n); 
    for(int i=0;i<n;i++){
        ll a, b;
        cin >> a >> b;
        v[i] = P(a,b);
    }
    sort(v.begin(), v.end());
    ll ans = v.back().first+v.back().second;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
while True:
  a, op, b = input().split()
  a, b = int(a), int(b)
  if op == '+':
    print(a + b)
  elif op == '-':
    print(a - b)
  elif op == '*':
    print(a * b)
  elif op == '/':
    print(a // b)
  else:
    break


Measured memory_bytes: 5600
#include <bits/stdc++.h>
#define int long long
using namespace std;

typedef pair<int,int> P;
typedef pair<int,P> P1;

int N;

signed main(){
  
  cin>>N;
  
  vector<P1> A;
  
  for(int i=0;i<N;i++){
    int a, b;
    cin>>a>>b;
    A.push_back( P1( a+b , P( a, b ) ) );
  }
  
  sort(A.begin(), A.end());
  
  int sumA = 0, sumB = 0;
  
  int flg = 0;
  
  for(int i=N-1;i>=0;i--){

    if(!flg) sumA+=A[i].second.first;
    if(flg) sumB+=A[i].second.second;
    flg = !flg;
  }

  cout<<sumA-sumB<<endl;
  
  return 0;
}


Measured memory_bytes: 4620
#include <cstdio>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iostream>
#include <queue>
using namespace std;
typedef long long LL;
const LL N = 100005;
const LL M = 1000000;
const LL INF = 0x3f3f3f3f;
const LL MOD = 998244353;
const double eps = 1e-8;
LL n,m;
LL num[N];
LL a;
int main () 
{
    while (~scanf("%lld",&n))
    {
        memset(num,0,sizeof num);
        for (LL i=0;i<n;i++)
        {
            scanf("%lld",&a);
            num[a%4]++;
        }
        LL f = num[0];
        LL x = num[2];
        LL tmp = n-f-x;
        // cout<<f<<" "<<x<<" "<<tmp<<endl;
        LL ans=0;
        if (f+1<tmp)
            ans=1;
        if (f==0 && tmp>0)
            ans=1;
        if (f+1==tmp && x>0)
            ans=1;
        if (ans)
            printf("No\n");
        else
            printf("Yes\n");
    }
    return 0;
}

/*

3
1 10 100
4
1 2 3 4
3
1 4 1
2
1 1
6
2 7 1 8 2 8

*/

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 
#define PI 3.141592653589793238

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;
typedef gp_hash_table<long int,long int> HashTable;

int main(){
   IOS;
 /*    #ifndef ONLINE_JUDGE
         freopen("in.txt",  "r",  stdin);
         freopen("out.txt", "w", stdout);
     #endif */
   
   long int a,b;
   cin>>a>>b;

   long int min = (100 * a + 7) / 8;
   long int min2 = (100 * b + 9) / 10;

   long int ans = max(min,min2);
   long int check1 = 8 * ans / 100;
   long int check2 = 10 * ans / 100;

   if(check1 == a && check2 == b)
   	cout<<ans;
   else
   	cout<<"-1";
   return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e16;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

struct edge {ll to, cost;};
const ll mx = 1e5 + 100;
vector<edge> ed[mx];
ll N;

vl dijkstra(ll st){
    vl dist(N, LINF); dist[st] = 0;
    priority_queue<PL,vector<PL>, greater<PL>> q;
    q.push({0,st});
    while (!q.empty()) {
        auto tmp = q.top(); q.pop();
        ll now = tmp.ss, dis = tmp.ff;
        if(dist[now] < dis) continue;
        for(auto& e : ed[now]){
            if(dist[e.to] > dis + e.cost){
                dist[e.to] = dis + e.cost;
                q.emplace(dist[e.to], e.to);
            }
        }
    }
    return dist;
}

int main(){
    cin >> N;
    
    REP(i, N-1){
        ll a, b; cin >> a >> b;
        a--; b--;
        ed[a].pb({b,1}); ed[b].pb({a,1});
    }
    auto df = dijkstra(0);
    auto ds = dijkstra(N-1);

    ll cnt = 0;
    REP(i, N){
        if(df[i] <= ds[i]) cnt++;
    }
    cout << (cnt >= N/2+1 ? "Fennec" : "Snuke") << endl;
    return 0;
}


Measured memory_bytes: 9872
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
int n,k;
int main(){
	cin>>n>>k;
	if (k==1) puts("0");
	else cout<<(n-k+1)-1<<endl;
	return 0;
}

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

int main(){
int n,m;
cin>>n>>m;
int cnt=0;
vector<vector<int>> w(m+2);
priority_queue <int> que;
rep(i,n){
  int a,b;
  cin>>a>>b;
  if (a>m+1)continue;
  w[a].emplace_back(b);
}
ll ans=0;
for (int i=1;i<m+1;i++){
  for (auto j:w[i]){
  que.push(j);
}
if (!que.empty()){
ans+=que.top();
que.pop();
}
}
cout<<ans;
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
int n,k,sum;


int main() {
	// your code goes here
	cin>>n>>k;
	vector<int> v(n);
	for(int i=0;i<n;++i)
	cin>>v[i];
	sort(v.begin(),v.end());
	for(int i=n-1;i>=n-k;i--)
	sum+=v[i];
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100001,INF=1<<30;

int main(){
    int N,total=0;cin>>N;
    vector<int> A(N),B(31,0);
    for(int i=0;i<N;i++){
        cin>>A[i];
        for(int j=0;j<31;j++){
            if(A[i]&(1<<j)){ B[j]++;
            break;
            }
        }
        total=total^A[i];
    }

    int ans=0;

    for(int j=30;j>=0;j--){
        if(total&(1<<j)){
            if(B[j]){
                ans++;
                total=(total^(1<<j))^((1<<j)-1);
            }else ans-=1000;
        }
    }

    if(ans>=0) cout<<ans<<endl;
    else cout<<-1<<endl;
}


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

const int maxn=2e6+7;
int w[maxn],e[maxn],a[maxn];

vector<pair<int,int> >vec;

bool cmp(pair<int,int>a,pair<int,int> b) {return a.second<b.second;}

int main (){
    int n,m,k;cin>>n>>m>>k;
    cout<<min(k,m/n)<<endl;
    return 0;
}



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

namespace PrimeNumber
{
    class Program
    {
        private static bool?[] arr = new bool?[1000000];

        private static bool Save(int n, bool b)
        {
            arr[n] = b;
            return b;
        }

        private static bool IsPrime(int n)
        {
            if (arr[n] != null) return (bool)arr[n];
            if (n < 2) return Save(n, false);
            if (n == 2) return Save(n, true);
            if (n % 2 == 0) return Save(n, false);

            double l = Math.Sqrt(n);

            for (var i = 3; i <= l; i += 2)
                if (n % i == 0) return Save(n, false);
       
            return Save(n, true);
        }

        static void Main(string[] args)
        {
            int num;
            
            while (int.TryParse(Console.ReadLine(), out num))
                Console.WriteLine(Enumerable.Range(2, num - 1)
                .Where(i => IsPrime(i))
                .Count());
        }
    }
}


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

long long tens[15];
long long pows[15];

int main()
{
    string s;
    cin>>s;
    long long val,i,len=s.size();
    long long nrp=len-1;
    tens[0]=1;

    for(i=1;i<=10;i++) tens[i]=tens[i-1]*10;

    long long p=1<<nrp;
    pows[0]=p;
    i=len-1;
    int pas=1,j;
    long long sol=0;

    while(i>=0)
    {
        val=s[i]-'0';
        for(j=0;j<pas;j++)
        {
            sol+=pows[j]*tens[j]*val;
        }
        pows[pas]=pows[pas-1]/2;
        pows[pas-1]/=2;
        pas++;
        i--;

    }
    cout<<sol<<'\n';
    return 0;
}


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

int f(ll a, ll b) {
    return max(to_string(a).length(), to_string(b).length());
}

int main() {
    ll N;
    cin >> N;
    vector<ll> divs;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            divs.push_back(i);
            divs.push_back(N / i);
        }
    }

    int ans = 1000;
    for (ll d : divs) {
        ans = min(ans, f(d, N / d));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
using pii = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const int N = 1e6 + 10;
 
struct IOsetup{
  IOsetup(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); 
    cout.tie(nullptr);
    cout << fixed << setprecision(20);
  }
}IO;


int32_t main(){
 string a, b;
 cin >> a >> b;
 cout << b + a << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100111;
const int inf=1000000007;
const long long INF=1000000000000000007;
using ll=long long;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};


int main(){
	int n;
	P p[2*M];
	cin>>n;
	rep(i,0,n)cin>>p[i].second>>p[i].first;
	sort(p,p+n);
	ll time=0;
	rep(i,0,n){
		time+=p[i].second;
		if(time>p[i].first){
			print("No");
			return 0;
		}
	}
	print("Yes");
	return 0;
}	

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

using namespace std;

int main(void){
    int N,ans=0,max=-1000000;
    int i,p;

    cin>>N;
    for(i=0;i<N;i++){
        cin>>p;
        ans=ans+p;
        if(p > max){
            max=p;
        }
    }
    ans=ans-max/2;

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
  int a,b,t;
scanf("%d%d",&a,&b);
if(a<b){
	t=a;
	a=b;
	b=t;
}
for(;;){
if(b==0)break;	
t=a%b;
a=b;
b=t;
}
printf("%d\n",a);
  return 0;
}



Measured memory_bytes: 2104
h,w,c,S,max,C,N,r;
int *_M;
D(x,y){
	_M[x+(w+2)*y]=N;
	if(_M[x-1+(w+2)*y]==C)r++,D(x-1,y);
	if(_M[x+1+(w+2)*y]==C)r++,D(x+1,y);
	if(_M[x+(w+2)*(y-1)]==C)r++,D(x,y-1);
	if(_M[x+(w+2)*(y+1)]==C)r++,D(x,y+1);
}
E(int d,int *M){if(d<4||M[1+w+2]!=c){
	int *m=malloc(S);
	if(d==4){
		memcpy(_M=m,M,S);
		C=m[1+w+2],N=c;D(1,1);
		C=c,N=-1,r=1;D(1,1);
		if(max<r)max=r;
	}else{
		int i=1;
		for(;i<7;i++)if(M[1+w+2]!=i){
			memcpy(_M=m,M,S);
			C=m[1+w+2],N=i;D(1,1);
			E(d+1,m);
		}
	}
	free(m);
}}
a[100];
main(i,j){for(;scanf("%d%d%d",&h,&w,&c),c;printf("%d\n",max)){
	memset(a,0,S=4*(w+2)*(h+2));
	for(j=1;j<h+1;j++)for(i=1;i<w+1;i++)scanf("%d",a+i+(w+2)*j);
	E(max=0,a);
}}

Measured memory_bytes: 620
#include<iostream>
using namespace std;
int main(){
	int a,b;
	cin >> a >> b;
	if (a > b){
		cout << "a > b" << endl;
	}
	else if (a == b){
		cout << "a == b" << endl;
	}
	else{
		cout << "a < b" << endl;
	}
	return 0;
}

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

int main() {
  int H, W;
  for (int i=0; ; i++) {
    cin >> H >> W;
    if (i != 0) cout << endl;
    if (H == 0 && W == 0) break;
    for (int j=0; j<H ; j++) {
      for (int k=0; k<W; k++) {
        if (k != W-1) cout << "#";
        else cout << "#" << endl;
      }
    }
  }
  return 0; 
}


Measured memory_bytes: 3060
n = int(input())
a = list(map(int,input().split()))
c = [0,0,0,0,0,0,0,0]
at = 0
for i in range(n):
    if 1<=a[i]<=399:
        c[0]+=1
    elif 400<=a[i]<=799:
        c[1]+=1
    elif 800<=a[i]<=1199:
        c[2]+=1
    elif 1200<=a[i]<=1599:
        c[3]+=1
    elif 1600<=a[i]<=1999:
        c[4]+=1
    elif 2000<=a[i]<=2399:
        c[5]+=1
    elif 2400<=a[i]<=2799:
        c[6]+=1
    elif 2800<=a[i]<=3199:
        c[7]+=1
    else:
        at+=1
cnt=0
for i in c:
    if i >0:
        cnt+=1
ans_max=cnt+at 

if cnt==0:
    cnt=1
print(str(cnt)+" "+str(ans_max))



Measured memory_bytes: 61352
#!/usr/bin/ruby
# coding: utf-8

PI = Math.acos(-1)

while true
  line = gets
  if line == nil
    break
  end
  line = line.chomp
  i = 0
  while i < line.length
    c = line[i]
    if c == '@'
      for k in 1..(line[i+1].to_i)
        print line[i+2]
      end
      i += 3
    else
      print c
      i += 1
    end
  end
  puts ''
end

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

int n, m, t;
char s[255][256];

void check(int i, int j) {
	if (s[i][j] == '1') {
		t++;
		m = max(m, t);
	}
	else
		t = 0;
}

int main()
{	
	cin >> n;

	while (n > 0) {
		memset(s, 0, sizeof(s));

		for (int i = 0; i < n; i++)
			cin >> s[i];

		m = 0;
	
		for (int i = 0; i < n; i++) {
			t = 0;
			for (int j = 0; j < n; j++)
				check(i, j);
		}

		for (int i = 0; i < n; i++) {
			t = 0;
			for (int j = 0; j < n; j++)
				check(j, i);
		}

		for (int i = 0; i < n * 2 - 1; i++) {
			t = 0;
			for (int j = max(0, i - n); j <= min(i, n - 1); j++)
				check(i - j, j);
		}

		for (int i = 0; i < n * 2 - 1; i++) {
			t = 0;
			for (int j = max(0, n - 1 - i); j <= min(n - 1, n * 2 - 2 - i); j++)
				check(j, j + i - n + 1);
		}

		cout << m << endl;

		cin >> n;
	}

	return 0;
}


Measured memory_bytes: 3132
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define iter(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define riter(i, c) for (auto i = (c).rbegin(); i != (c).rend(); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A[3];
    rep(i, 0, 3) cin >> A[i];
    int sum = 0;
    rep(i, 0, 3) sum += A[i];
    if (sum >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
    return 0;
}

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

#define int long long
typedef vector<vector<int>> Mat;
Mat mul(Mat a,Mat b){
	Mat c = a;
	for(int i = 0 ; i < a.size() ; i++){
		for(int j = 0 ; j < a.size() ; j++){
			c[i][j] = 0;
			for(int k = 0 ; k < a.size() ; k++){
				c[i][j] += a[i][k] * b[k][j];
				c[i][j] %= 1000000007;
			}
		}
	}
	return c;
}
Mat mpow(Mat a,long long n){
	Mat e = {{1,0},{0,1}};
	if( n == 0 ) return e;
	e = mpow(mul(a,a),n/2);
	if( n & 1 ) e = mul(e,a);
	return e;
}

/*
	fn+1  01 f(n)
	fn+2  11 f(n+1)


*/
long long fib(int n){
	Mat m = {{0,1},{1,1}};
	Mat e = {{1,0},{0,1}};
	e = mpow(m,n);
	return e[0][0] + e[0][1];
	/*if( n <= 1 ) return 1;
	if( dp[n] ) return dp[n];
	return dp[n] = fib(n-1) + fib(n-2);	
	*/
}


long long inf = 4e18;
// [0,r]??£????????±
long long total(long long r){
	r++;
	long long k = r / 2;
	if( (double)k*(k-1) > inf ) return inf;
	long long tot = k*(k-1);
	if(r%2==1)tot += k;
	return tot;
}

long long calc(long long n){
	
	long long l = 0 , r = 1e18;
	while( l != r ){
		long long m = (l+r+1) / 2;
		if( total(m) > n ){
			r = m-1;
		}else{
			l = m;
		}
	}
	long long pos = n - total(l);
	long long row = l + 1;
	long long mid = row / 2;
	long long col;
	if( 2*pos >= mid ){
		col = mid - (2*pos - mid)-1;
	}else{
		col = 2*pos;
	}
	//cout << row << " " << col << endl;

	col++;
	return fib(row-col) * fib(col) % 1000000007;
}
signed main(){
	long long n;
	cin >> n;
	--n;
	cout << calc(n) << endl;

}

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

int main() {
  int N,M;
  cin >> N >> M;
  vector<vector<int>> circuit(M);
  vector<int> mod(M);
  for(int i=0; i<M; i++){
    int k;
    cin >> k;
    for(int j=0; j<k; j++){
      int s;
      cin >> s;
      s--; // 1-indexed -> 0-indexed
      circuit.at(i).push_back(s);
    }
  }
  for(int i=0; i<M; i++){
    cin >> mod.at(i);
  }

  int ans= 0;
  for(int tmp=0; tmp<(1<<N); tmp++){
    bitset<10> bits(tmp);
    bool satisfied= true;
    for(int i=0; i<M; i++){
      int sum= 0;
      for(int j=0; j< circuit.at(i).size(); j++){
        if(bits.test(circuit.at(i).at(j))){
          sum++;
        }
      }
      if(sum%2 != mod.at(i)){
        satisfied= false;
        break;
      }
    }

    if(satisfied) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
using namespace std;

int main()
{
    int n, k, x, y;
    cin >> n >> k >> x >> y;

    if(n <= k)
    	cout << n * x;
    else
    	cout << k * x + (n - k) * y;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
#define LLINF (1LL<<60)
#define INF (1<<30)
#define F first
#define S second
int main(void){
    string s;
    long long ans=0;
    char b='U';
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(b!=s[i]){
            ans++;
            b=s[i];
        }
    }
    cout<<ans-1<<endl;
}

Measured memory_bytes: 512
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll INF = 1e18;

int main() {
  //
  ll n;
  cin >> n;
  vvl edges(n);
  rep(i, n - 1) {
    ll a, b;
    cin >> a >> b;
    a--, b--;
    edges[a].emplace_back(b);
    edges[b].emplace_back(a);
  }
  vl dist1(n, INF), distn(n, INF);
  queue<ll> que;
  que.push(0);
  dist1[0] = 0;
  while (!que.empty()) {
    ll u = que.front();
    que.pop();
    for (auto& v : edges[u]) {
      if (dist1[v] > dist1[u] + 1) {
        dist1[v] = dist1[u] + 1;
        que.push(v);
      }
    }
  }
  distn[n - 1] = 0;
  que.push(n - 1);
  while (!que.empty()) {
    ll u = que.front();
    que.pop();
    for (auto& v : edges[u]) {
      if (distn[v] > distn[u] + 1) {
        distn[v] = distn[u] + 1;
        que.push(v);
      }
    }
  }
  ll cnt0 = 0;
  rep(i, n) {
    if (dist1[i] <= distn[i]) cnt0++;
  }
  if (cnt0 > n - cnt0) {
    cout << "Fennec" << endl;
  } else {
    cout << "Snuke" << endl;
  }
  return 0;
}


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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9  //
#define LINF (ll)4e18  //
#define MOD (int)(1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define PI 3.1415926535898

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

int main() {
    int a, b;
    cin >> a >> b;
    string s;
    cin >> s;

    bool form = true;

    rep(i, a) {
        if (s[i] == '-') form = false;
    }
    if (s[a] != '-') form = false;

    REP(i, a + 1, a + b + 1) {
        if (s[i] == '-') form = false;
    }

    Yes(form);

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<vector>
#include<deque>
#include <numeric>
#include<cmath>
using namespace std;
#define ll long long
typedef pair<int,int>P;
int main(void){
    int x,a;
    cin >> x>> a;
    if(x<a){
        cout << 0<<endl;
    }else{
        cout << 10<<endl;
    }
    return 0;
}


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

using namespace std;
typedef long long ll;

int main(){

  int a1, a2, a3;
  cin >> a1 >> a2 >> a3;
  int ans = max(a1, max(a2, a3)) - min(a1, min(a2, a3));
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
from sys import stdin
n=list(map(int,(stdin.readline().strip().split())))
S =list(set(map(int,stdin.readline().strip().split())))
q=list(map(int,(stdin.readline().strip().split())))
T=list(map(int,stdin.readline().strip().split()))
S.sort(),T.sort()
count=0
c=-1

for t in T:
    SS=S
    while(True):
        n = len(SS)
        target = int((n - 1) / 2)#真ん中
        if SS[target] ==t:
            count+=1
            break
        if SS[target] >t:#下いく
            SS=SS[:target]
        else:#上いく
            SS=SS[target:]
        if n==len(SS):
            if n==1:break
            if SS[1] == t or SS[0]==t:
                count += 1
                break
            break


print(count)




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

int mod=1000000007;

int64_t step(pair<int,int> p){
  int freesteps=p.second-p.first-1,
      i0=0,
      i1=1,
      ans=i0+i1;
  while (freesteps>0){ //場合の数はフィボナッチ数列になる
    i0=i1;
    i1=ans%mod;
    ans=i0+i1;
    freesteps--;
  }
  return ans%mod;
}

int main(){
  int n,m;
  cin>> n >> m;
  vector<pair<int,int>> a(m+1);
  int start=0,broken;
  bool possible=true;
  for (int i=0; i<m; i++){
    cin>> broken;
    if (start==broken){ //壊れた段が連続していたら不可能
      possible=false;
      break;
    }
    a.at(i)=make_pair(start,broken-1);
    start=broken+1;
  }
  a.at(m)=make_pair(start,n);
  
  int64_t ans=1;
  if (possible){
    for (auto i: a) ans=(ans%mod)*step(i);
  }
  else ans=0;
  cout<< ans%mod << endl;
}

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int n;
    cin >> n;
    set<char> s;
    rep(i, n)
    {
        char c;
        cin >> c;
        s.insert(c);
    }
    if (s.size() == 3)
    {
        puts("Three");
    }
    else
    {
        puts("Four");
    }
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/dp/tasks/dp_e
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define DESPACITO 1000000000000000000
#define ll long long
using namespace std;
#define max(a,b) (a>b?a:b)
typedef pair<int, int> pii;
const int N = 100 + 5;
const int M = 1e5 + 5;
int val[N], wt[N];
ll dp[N][M];
int32_t main() {
    IOS;
    int i, j, n, W, ans = 0;
    cin >> n >> W;
    for(i = 1; i <= n; i++) 
        cin >> wt[i] >> val[i];
    for(i = 0; i <= n; i++)
        for(j = 0; j <= M; j++)
            dp[i][j] = DESPACITO;
    dp[0][0] = 0;
    for(i = 1; i <= n; i++) 
        for(j = 0; j < M; j++) 
            dp[i][j] = min(dp[i-1][j], wt[i] + dp[i-1][max(0, j-val[i])]);
    for(i = 1; i <= M; i++) 
        if (dp[n][i] <= W) ans = i;
    cout << ans;
    return 0;
}

Measured memory_bytes: 80128
#include <iostream>
using namespace std;
int main(int argc, const char * argv[])
{
    int r;
    cin>>r;
    if(r<1200)
        cout<<"ABC"<<endl;
    else if(r<2800)
        cout<<"ARC"<<endl;
    else
        cout<<"AGC"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int search(int A[],int n,int key){
  int i=0;
  A[n]=key;
  while(A[i]!=key)
    i++;
  return i!=n;
}

int main(){
  int i, n, A[10000+1],q,key,sum=0;

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

  scanf("%d",&q);
  for(i=0; i<q; i++){
    scanf("%d",&key);
    if(search(A,n,key))
      sum++;
  }
  printf("%d\n",sum);

  return 0;
}



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

int main() {
  string s;
  int k;
  cin >> s >> k;
  int n = s.length();
  int cnt = 0;
  vector<string> c;
  rep(i, 26) {
    map<string, bool> ma;
    rep(j, n) {
      if ((char)(i + 'a') == s[j]) {
        for (int k = 1; k <= 5; k++) {
          if (j + k > n) break;
          if (ma[s.substr(j, k)] == false) {
            c.push_back(s.substr(j, k));
            ma[s.substr(j, k)] = true;
            cnt++;
          }
        }
      }
    }
    if (cnt >= k) {
      break;
    }
  }
  sort(c.begin(), c.end());
  cout << c[k - 1] << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long  n,max,min;
	int i;
	cin>>n;
	cin>>max;
	min=max;
	int x;
	for(i=1;i<n;i++){
		cin>>x;
		if(max<x)
			max=x;
		if(min>x)
			min=x;
	}
	cout<<max-min;
	return 0;
}

Measured memory_bytes: 256
from collections import Counter,defaultdict
import sys,bisect,math,itertools,string,queue
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())

k,a,b = inpl()
t = k-(a-1)
if b-a > 2 and t >= 2:
    if t % 2:        
        print(b+(t//2-1)*(b-a)+1)
    else:
        print(b+(t//2-1)*(b-a))
else:
    print(1+k)

Measured memory_bytes: 3956
#include <iostream>

using namespace std;

int main() {
    int n;
    cin>>n;
    switch(n%10){
        case 0:cout<<"pon";break;
        case 1:cout<<"pon";break;
        case 6:cout<<"pon";break;
        case 8:cout<<"pon";break;
        case 3:cout<<"bon";break;
        default:cout<<"hon";
    }
}

Measured memory_bytes: 3640
#include <stdio.h>

int main()
{
  int vetor[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 n;
  scanf("%d", &n);
  printf("%d\n",vetor[n-1]);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    string s;
    cin >> s;
    int n = s.size();
    if (s[0] == '0' || s[n-1] == '1') {
        puts("-1");
        return 0;
    }
    for (int i = 0; i < n-1; ++i) {
        int j = n-2-i;
        if (s[i] != s[j]) {
            puts("-1");
            return 0;
        }
    }
    int pre = n;
    vector<P> ans;
    for (int i = n-1; i >= 1; --i) {
        ans.push_back(P(pre, i));
        if (s[i-1] == '1') {
            pre = i;
        }
    }
    rep(i, n-1) {
        cout << ans[i].fi << " " << ans[i].se << endl;
    }
}


Measured memory_bytes: 4480
#include<bits/stdc++.h>
#define bug(x) cout<<#x<<" : "<<x<<endl
#define de puts("#")
using namespace std;

int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	printf("%d\n",max(a+b,max(a-b,a*b)));
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define ll int
#define bits_count __builtin_popcountll
#define endl '\n'
#define double long double
#define ld double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
#define pr pair<int,int>
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }
    
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
// struct chash { int operator()(int x) const { return x ^ RANDOM; }};
// cc_hash_table<int, int, hash<int>> cnt;

const int MAXN = 3005;
int dp[MAXN][MAXN];
int A,B,C,D; 
const int MOD = 998244353;

int rec(int x,int y){
    if(x < 0 || y < 0) return 0;
    if(x == A && y == B) return 1;

    int &ans = dp[x][y];
    if(ans != -1) return ans;
    return ans = (x*rec(x,y-1) + y*rec(x-1,y) - ((x-1)*(y-1))%MOD*rec(x-1,y-1))%MOD;
}

void solve(){
    MINUS(dp);
    cin>>A>>B>>C>>D;
    cout<<(rec(C,D)+MOD)%MOD<<endl;
}
    
signed main(){
    
    FastRead;     
    
    int t = 1; 
    // cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}
    




Measured memory_bytes: 74504
#include <bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
#define cin(a) scanf("%d",&a)
#define pii pair<int,int>
#define ll long long
#define gcd __gcd
const int inf = 0x3f3f3f3f;
const int maxn = 201110;
const int M = 1e9+7;
int n,m,k,t;

int main()
{
	ll h;
	cin>>h;
	ll ans = 0;
	ll res = 1;
	while(h)
	{	
		ans += res;
		res *= 2;
		h /= 2;
	}
	cout<<ans<<endl;
	return 0;
}

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

typedef long long ll;
#define ALL(a) a, a+sizeof(a)/sizeof(a[0])
#define all(a) a.begin(),a.end()
#define MOD 1000000007
using namespace std;
ll gcd(ll n, ll m) {
	if (m == 0) return n;
	return gcd(m, n % m);
}
ll lcm(ll n, ll m) {return m / gcd(n, m) * n;}

int main(void) {
	ll h1, h2, k1, k2, a, b, c, d;
	cin >> h1 >> h2 >> k1 >> k2 >> a >> b >> c >> d;
	ll hiro = h1 * a + h1 / 10 * c + h2 * b + h2 / 20 * d;
	ll ken = k1 * a + k1 / 10 * c + k2 * b + k2 / 20 * d;

	if (hiro > ken)
		cout << "hiroshi" << endl;
	else if (hiro < ken)
		cout << "kenjiro" << endl;
	else
		cout << "even" << endl;
	return 0;
}


Measured memory_bytes: 3120
N,M,C = map(int,input().split())
B = list(map(int,input().split()))

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

count = 0
for i in range(N):
    total = C
    for j in range(M):
        total += A[i][j]* B[j]
    if total>0 :
        count += 1
        
print(count)
    

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
using namespace std;
int main(){
    string s;
    cin>>s;
    for(int i=0;i<s.length();i+=2){
        cout<<s[i];
    }
    cout<<endl;
}   




Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 1000000000000007ll;

const double eps = 1e-10;

const i64 MAXN = 200005;

i64 n, k;

struct less_key {
    bool operator()(const pair<i64, i64>& a, const pair<i64, i64>& b) {
        return a.first + a.second < b.first + b.second;
    }
};

vector<pair<i64, i64>> R;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    cin >> n >> k;

    i64 l = k;
    i64 r = k + 2 * n - 1;

    i64 t = n / 2 + n % 2;

    for (i64 i = (1 - n % 2) + l, j = r - t + 1, k = 0; k < t; i++, j++, k++) {
        R.push_back({i, j});
    }

    for (i64 i = (1 - n % 2) + l + t, j = r - t - (t - 1) + 1, k = 0; k < (t - 1); i++, j++, k++) {
        R.push_back({i, j});
    }

    if (n % 2 == 0) {
        R.push_back({k, k + n});
    }


    sort(R.begin(), R.end(), less_key());

    bool f = true;
    for (i64 i = 0; i < n; i++) {
        if (R[i].first + R[i].second > k + 2 * n + i) {
            f = false;
            break;
        }
    }

    if (!f) {
        cout << -1 << endl;
        return 0;
    }


    for (i64 i = 0; i < n; i++) {
        cout << R[i].first << " " << R[i].second << " " << k + 2 * n + i << endl;
    }

    return 0;
}


Measured memory_bytes: 4336
import sys

N, K = map(int, input().split())
S = input()

isOneFound = False
ruiseki = []
if S[0] == "0":
    ruiseki.append(0)

for i in range(N):
    if i == N-1:
        ruiseki.append(i+1)
        continue
    if S[i] != S[i+1]:
        ruiseki.append(i+1)

if S[-1] == "0":
    ruiseki.append(N)

#print(ruiseki)

# 全部ひっくり返せる場合
if K >= (len(ruiseki)-1) // 2:
    print(N)
    sys.exit(0)


l = 0
r = 2 * K
ans = -1
while r < len(ruiseki):
    if l > 0:
        tmp = ruiseki[r] - ruiseki[l-1]
    else:
        tmp = ruiseki[r]
    ans = max(ans, tmp)
    l += 2
    r += 2

print(ans)


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

string past;
string now;
int main ()
{
	cin >> past >> now ;
	
	int res=0 ;
	
	for (int i=0 ; i < past.length() ; i++)
	{
		if (past[i] == now [i])
		{
			res++;
		}		
	}
	
	cout << res ;
}

Measured memory_bytes: 764