akhauriyash/Code-Regression huggingface dataset:
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#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>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif




#define int long long
#define rng(i,l,r) for(size_t i=(l);i<(r);++i)
#define rep(i,n) rng(i,0,n)
#define gnr(i,l,r) for(size_t i=(r)-1;i>=(l);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()   //1,2,3,...
#define rALL(obj) (obj).rbegin(), (obj).rend()//...,3,2,1

using namespace std;
//using ll = long long;


const int MOD = 1000000007;
const int INF = 1e18;

const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

const double pi = acos(-1);



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


using Graph = vector<vector<int>>;



void solve(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int L,R; cin >> L >> R;
    int ans = INF;
    if(R-L > 2030) ans = 0;
    else{
        for (int i = L; i <= R; i++) {
            for (int j = L; j <= R; j++) {
                
                if(i==j) continue;
                if(i<j) continue;
                ans = min(ans, (i*j)%2019);
                
                
            }
        }
    }
    
    
    cout << ans << endl;
}



signed main() {
    solve();
    return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {

			String S = br.readLine();

			String str = br.readLine();

			int res = (S+S).indexOf(str);

			if(res == -1){
				System.out.println("No");
			}else{
				System.out.println("Yes");
			}
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (br != null) {
				try {
					br.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}

		}
	}
}

Measured memory_bytes: 24336
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <sstream>
#include <cassert>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <random>
#include <chrono>
#include <ctime>

using namespace std;

#define en '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) int((x).size())

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair <ll, ll> pll;

const int INF = 1e9 + 7;
const ll INFLL = 1e18;
const double EPS = 1e-9;
const double PI = 3.1415926535897932384626433832795;
const int MAX_SIZE = 5e5;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

bool IS_ONE_TEST = 1;
ld START_TIME, TIME;

void fast_in_out() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

void solve() {
    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    sort(all(a));
    ll ans = 0;
    for (int i = 0; i < k; ++i) ans += a[i];
    cout << ans << en;
}

int main() {
    START_TIME = clock();
    fast_in_out();
    int TESTS = 1;
    if (!IS_ONE_TEST) cin >> TESTS;
    while (TESTS--) { solve(); }
#ifdef __APPLE__
    TIME = (clock() - START_TIME) / CLOCKS_PER_SEC;
    cerr << en << TIME * 1000 << " ms." << en;
#endif
    return 0;
}

/*
     ▄▀▀▀▄
▄███▀░◐░░░▌
    ▌░░░░░▐
    ▐░░░░░▐
    ▌░░░░░▐▄▄
    ▌░░░░▄▀▒▒▀▀▀▀▄
   ▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
   ▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
    ▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
      ▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
           ▌▌░▌▌
           ▌▌░▌▌
         ▄▄▌▌▄▌▌        */


Measured memory_bytes: 3236
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>
//#include <bits/stdc++.h>
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
using namespace std;
#define ALL(X) X.begin(),X.end()
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=2147483647;
const ll LLMAX=9223372036854775807;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N,L;
    cin>>N>>L;
    vll a(N);
    for(ll i=0;i<N;i++)cin>>a[i];
    
    ll index=-1;
    for(ll i=0;i<N-1;i++){
        if(a[i]+a[i+1]>=L){
            index=i;
            break;
        }
    }
    
    if(index==-1){
        cout<<"Impossible"<<endl;
    }else{
        cout<<"Possible"<<endl;
        for(ll i=0;i<index;i++)cout<<i+1<<endl;
        for(ll i=N-2;i>index;i--)cout<<i+1<<endl;
        cout<<index+1<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define ZERO(a) memset(a,0,sizeof(a))
#define FILL(a,b) memset(a,b,sizeof(a))
#define SORT(v) sort((v).begin(),(v).end())
#define RSORT(v) sort((v).rbegin(),(v).rend())
#define FOR(i,a,b)  for(int i=a, i##_len=(b); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
using namespace std;
string S, T;

int main(void) {
    cin >> S;
    cin >> T;

    cout << T+S << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
typedef priority_queue<string> priquest;
typedef priority_queue<string,vector<string>,greater<string>> rpriquest;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}
ll lcm(ll l,ll a){
    return a/__gcd(l,a)*l;
}
ll exp(ll a, ll b,ll c){
  if(b==0)return 1;
  if(b%2==0){
    ll t =exp(a,b/2,c);
    return t*t%c;
  }
  else return exp(a,b-1,c)*a%c;
}
const ll big=1000000007;

int exp(int a, int b, int c){
  if(b==0)return 1;
  if(b%2==0){
int t =exp(a,b/2,c);
return t*t%c;
  }
  else return exp(a,b-1,c)*a%c;
}


int main(){
    string s;cin >> s;
    vector<int> ruiseki2019(s.size()+1); //[0]には0を入れておけばよい
    reverse(s.begin(),s.end());
    vector<int> mo2019(2019);
    
    rep(i,s.size()){
        ruiseki2019[i+1]=(ruiseki2019[i]+exp(10,i,2019)*(s[i]-'0'))%2019;
    }
    rep(i,s.size()+1)mo2019[ruiseki2019[i]%2019]++;
    ll ans=0;
    
    rep(i,2019){
        ans+=mo2019[i]*(mo2019[i]-1)/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4368
def main():
    ans = []
    while True:
        n, r = map(int, input().split())
        if n == 0 and r == 0:
            break
        cards = []
        for i in range(n):
            cards.append(i+1)
        cards = cards[::-1]
        for i in range(r):
            p, c = map(int, input().split())
            cards = cards[p-1:p-1+c] + cards[:p-1] + cards[p-1+c:]
        ans.append(cards[0])

    for i in range(len(ans)):
        print(ans[i])

main()



Measured memory_bytes: 5636
#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

int main(void)
{
   int N, M;
   cin >> N >> M;
   vector<int> A(M), B(M);
   dsu d(N);
   for (int i = 0; i < M; i++)
   {
      cin >> A[i] >> B[i];
      A[i]--;
      B[i]--;
      d.merge(A[i], B[i]);
   }
   int ans = 0;
   vector<int> num(N, 0);
   for (int i = 0; i < N; i++)
   {
      num[d.leader(i)]++;
   }
   for (int i = 0; i < N; i++)
   {
      if (num[i] >= 1)
         ans++;
   }
   cout << ans - 1 << endl;
   return 0;
}


Measured memory_bytes: 4880
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/dynamic_bitset.hpp>
namespace adaptor = boost::adaptors;
using index_t = std::size_t;

namespace lib
{
	using graph_t = std::vector<std::set<index_t>>;
	template<class T>using weighted_graph_t = std::vector<std::map<index_t, T>>;

	struct max_t
	{
		template<class T>constexpr T operator()(T const& lhs, T const& rhs)const
		{
			return std::max(lhs, rhs);
		}
	};
	struct min_t
	{
		template<class T>constexpr T operator()(T const& lhs, T const& rhs)const
		{
			return std::min(lhs, rhs);
		}
	};

	constexpr max_t max;
	constexpr min_t min;

	template<class T>auto order_by(T func)
	{
		return [=](auto&& lhs, auto&& rhs)
		{
			return func(lhs) < func(rhs);
		};
	}

	template<class T>constexpr auto max_v = std::numeric_limits<T>::max();
	template<class T>constexpr auto min_v = std::numeric_limits<T>::min();

	template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;
}

void Main()
{
	int A, B;
	std::cin >> A >> B;
	std::cout << A * B << std::endl;
}

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

Measured memory_bytes: 3612
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) throws IOException{
		Scanner in = new Scanner(System.in);
		while(true){
			int n = in.nextInt();
			if(n ==0) break;
			int count = 0;
			for(int i=1; i<=n/2; i++){
				if(dfs(i, 0, n)) count++;
			}
			System.out.println(count);
		}
	}
	public static boolean dfs(int val, int sum, int n){
		if(sum>n) return false;
		else if(sum==n || dfs(val+1, sum+val, n)) return true;
		return false;
	}
}

Measured memory_bytes: 19832
def inv_mod(a, p):
    p = abs(p)
    a %= p
    stack = []
    p0 = p
    while a > 1:
        d, a, p = p//a, p%a, a
        stack.append(d)
    x, y = 1, 0
    while stack:
        d = stack.pop()
        x, y = y-d*x, x
    return x % p0

def comb_mod(n,k,p):
    ans = 1
    k = min(k,n-k)
    if k < 0:
        return 0
    for i in range(k):
        ans = ans * (n-i) * inv_mod(k-i,p) % p
    return ans

MOD = 10**9 + 7
K = int(input())
N = len(input())
f = 26 * inv_mod(25, MOD) % MOD
a = pow(25, K, MOD) * comb_mod(N+K-1, N-1, MOD)
ans = 0
for r in range(K+1):
    ans = (ans + a) % MOD
    a *= (f * (K-r) * inv_mod(N+K-r-1, MOD))
    a %= MOD
print(ans)


Measured memory_bytes: 70612
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define mp make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pll pair<ll,ll>
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<=n;i++)
ll mod=1000000007;
ll n,k,t,m,q,flag=0;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(a) -- no. of elements strictly less than a
// s.find_by_order(i) -- itertor to ith element (0 indexed)
ll min(ll a,ll b){if(a>b)return b;else return a;}
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll gcd(ll a , ll b){ if(b > a) return gcd(b , a) ; if(b == 0) return a ; return gcd(b , a%b) ;}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #ifdef NOOBxCODER
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #else 
    #define NOOBxCODER 0
    #endif
    //cin>>t;
    t=1;
    while(t--){
        cin>>n;
        string s[n];
        map<string ,ll>m1;
        ll ans=0;
        fo(i,n){
            cin>>s[i];
            if(m1[s[i]]==0)ans++;
            m1[s[i]]+=1;
        }
        cout<<ans;




        
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}


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

const long inf = 1e18;
long sub(long a, long b) {
  if (double(a) * b >= 1.1e18) return inf + 1;
  return a * b;
}

int main() {
  int n;
  cin >> n;
  long ans = 1;
  for (int i = 0; i < n; ++i) {
    long a;
    cin >> a;
    ans = sub(ans, a);
  }
  cout << (ans > inf ? -1 : ans) << endl;
}

Measured memory_bytes: 3612
#include <stdio.h>

int a[1000000], n;

int binary_search(int key) {
  int left = 0;
  int right = n;
  int mid;
  while (left < right) {
    mid = (left + right) / 2;
    if (key == a[mid]) return 1;
    if (key > a[mid]) left = mid + 1;
    else if (key < a[mid]) right = mid;
  }

  return 0;
}

int main() {
  int i, q, k, sum = 0;

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

  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d", &k);
    if (binary_search(k)) sum++;
  }
  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 2108
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int width = S.length();
        int cnt = 0;
        int forward = 0;
        int backward = 0;

        for (int i = 0; i < S.length(); i++) {
            if ((S.charAt(i) - 48) != ((i + 1) % 2)) {
                forward++;
            } else {
                backward++;
            }
        }

        System.out.println(Math.min(forward, backward));
    }
}


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

int main(){
  int m[3][3],i,j,a[3],b[3],k;
  bool flag=0;
  for(i=0;i<3;i++)
    for(j=0;j<3;j++)
      cin>>m[i][j];         
  for(i=0;i<=m[0][0];i++){
    a[0]=i;
    for(j=0;j<3;j++){
      b[j]=m[0][j]-a[0];
      if(j!=0)a[j]=m[j][0]-b[0];
    }
    for(j=0;j<3;j++){
      for(k=0;k<3;k++){
        if(m[j][k]!=a[j]+b[k]){
          flag=1;
          break;
        }
      }
      if(flag)break;
    }
    if(flag)break;
  }
  if(!flag)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
#define ll long long
void FastInputOutput(){
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}

ll power(ll x, ll p, ll m){
    ll res = 1;
    while(p){
        if(p&1)    res = (res * x)%m;
        x = (x * x)%m;
        p >>= 1;
    }
    return res;
}
long double ModLog(long double base, long double x) {
    return (logl(x) / logl(base));
}

const int N = 2e6 + 5, MX = 1e9;
char a[N];
int main(){
    scanf("%s", a);
    string s;
    s.push_back(a[0]);
    scanf("%s", a);
    s += a[1];
    scanf("%s", a);
    s += a[2];
    printf("%s", s.c_str());
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N, Q;
  string S;
  cin >> N >> Q >> S;
  vector<ll> accum(N, 0);
  for (int i = 1; i < S.size(); i++) {
    if (S[i - 1] == 'A' && S[i] == 'C') {
      accum[i] = accum[i - 1] + 1;
    } else {
      accum[i] = accum[i - 1];
    }
  }
  int l, r;
  for (int i = 0; i < Q; i++) {
    cin >> l >> r;
    cout << accum[r - 1] - accum[l - 1] << endl;
  }
  return 0;
}

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

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

vi g[100005];
int d[100005], d1[100005];

void dfs(int cur, int prev){
	if(prev == -1) d[cur] = 0;
	else d[cur] = d[prev] + 1;
	for(int u : g[cur]) if(u != prev) dfs(u, cur);
}

void dfs1(int cur, int prev){
	if(prev == -1) d1[cur] = 0;
	else d1[cur] = d1[prev] + 1;
	for(int u : g[cur]) if(u != prev) dfs1(u, cur);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	rep(i, n - 1){
		int a, b;
		cin >> a >> b;
		a--, b--;
		g[a].pb(b);
		g[b].pb(a);
	}
	memset(d, 0, sizeof(d));
	memset(d1, 0, sizeof(d1));
	dfs(0, -1);
	dfs1(n - 1, -1);
	int ans = 0;
	rep(i, n) if(d[i] <= d1[i]) ans++;
	if(ans <= (n - ans)) cout << "Snuke" << endl;
	else cout << "Fennec" << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 9472
n,k = map(int,input().split())

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
ans=Base_10_to_n(n,k)
print(len(ans))

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

// clang-format off
#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

#define rep(i, n) for (int i = 0; i < (int)(n); ++(i))
#define reps(i, n) for (int i = 1; i <= (int)(n); ++(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 range(i, l, r) for (int i = (int)l; i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = ((int)(r) - 1); i >= (int)l; --(i))

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

using int32 = int;
using int64 = long long;

constexpr int mod     = 1e9 + 7;
constexpr int32 inf   = 1001001001;
constexpr int64 infll = 1001001001001001001ll;
constexpr int dx[]    = {0, -1, 1, 0, -1, 1, -1, 1},
              dy[]    = {-1, 0, 0, 1, -1, -1, 1, 1};
const string YES = "YES", NO = "NO", Yes = "Yes", No = "No", yes = "yes", no = "no";

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

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

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

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

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

void solver() {
  int A = input(), B = input();
  int Q = input();

  vector<int64> s(A + 2), t(B + 2);
  range(i, 1, A + 1) cin >> s[i];
  range(i, 1, B + 1) cin >> t[i];

  s[0] = t[0] = -infll;
  s.back() = t.back() = infll;

  // debug(s);
  // debug(t);

  range(q, 0, Q) {
    int64 x = input();

    // debug(x);

    int s_idx = whole(lower_bound, s, x) - s.begin() - 1;
    int t_idx = whole(lower_bound, t, x) - t.begin() - 1;

    int64 ans = infll;
    range(i, s_idx, s_idx + 2) {
      range(j, t_idx, t_idx + 2) {
        chmin(ans, min(abs(x - s[i]) + abs(s[i] - t[j]), abs(x - t[j]) + abs(t[j] - s[i])));
      }
    }

    cout << ans << endl;
  }
}

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


Measured memory_bytes: 2944
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;

bool truck(long int M,int n,int k,int bag[]);

int main(){
    int n,k,bag[100000+10];
    cin >> n >> k;
    for(int j=0;j<n;j++){
        cin >> bag[j];
    }
    long int l=0;
    long int h=pow(2,31);
    bool test;
    while(l+1<h){
        long int m=(l+h)/2;
        test=truck(m,n,k,bag);
        if(test) h=m;
        else l=m;
    }
    cout << h << endl;

}

bool truck(long int M,int n,int k,int bag[]){
    int wgt=0,num=1;
    for(int i=0;i<n;i++){
        if(wgt+bag[i]<=M) wgt+=bag[i];
        else{
            num++;
            if(bag[i]<=M) wgt=bag[i];
            else{
                num=100000+10;
                break;
            }
        }
    }
    return num<=k;
}

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

int main() {
 int n,l,r;
 int sum = 0;
 cin >> n;
 for(int i = 0;i < n;i++){
   cin >> l >> r;
   sum += r - l + 1;
 } 
 cout << sum << endl;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
S = []
for i in range(H):
    S.append(input())
for i in range(H):
    for j in range(W):
        if S[i][j] == ".":
            S[i] = S[i].replace(".", "0", 1)
            rec = 0
            for d in [(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)]:
                nx, ny = i + d[0], j + d[1]
                if 0 <= nx < H and 0 <= ny < W and S[nx][ny] == "#":
                    rec += 1
            if rec > 0:
                S[i] = S[i][::-1]
                S[i] = S[i].replace("0", str(rec), 1)
                S[i] = S[i][::-1]

for i in range(H):
    print(S[i])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
bool vis[123];
int ans=0;
vector<int>ed[120];
int n,m;
void dfs(int a) {
	vis[a]=1;
	for(int i=0;i<ed[a].size();++i) {
		int tar=ed[a][i];
		if(vis[tar]==0)
			dfs(tar);
	}
	
	int mark=1;
	for(int i=1;i<=n;++i) {
		if(vis[i]==0)
			mark=0;
	}
	if(mark==1)
		ans++;
	vis[a]=0;
	return;
}
int main() {
	cin>>n>>m;
	int a,b;
	for(int i=0;i<m;++i) {
		cin>>a>>b;
		ed[a].push_back(b);
		ed[b].push_back(a);
	}
	dfs(1);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

ll mod(ll a){
  return (a % 1000000007);
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}

ll nCr(ll n,ll r){
  if(r == 1) return n;
  else if(r == 0) return 1;
  else return nCr(n-1,r-1)*n/r;
}

int main(){
  ll a,b,c,d; cin >> a >> b >> c >> d;
  
  if(abs(a-c) <= d || (abs(a-b) <= d && abs(c-b) <= d)){
    cout << "Yes" << endl;
  }
  
  else cout << "No" << endl;
  
}

Measured memory_bytes: 256
from collections import namedtuple, deque

P = namedtuple('P', 'id prev')

N, M  = map(int, input().split())
G = [[] for _ in range(N + 1)]

for _ in range(M):
  a, b = map(int, input().split())
  G[a].append(b)
  G[b].append(a)
  
# 履歴（最初に訪問した訪問元の番号が入る）  
visited = [None] * (N + 1)
  
q = deque([P(1, None)])
  
while q:
  p = q.popleft()
  if visited[p.id] is not None:
    continue
    
  visited[p.id] = p.prev
  
  for e in G[p.id]:
    if visited[e] is not None:
      continue
    q.append(P(e, p.id))
  
print('Yes')  # 常にYes?  

for i in range(2, N + 1):
  print(visited[i])

Measured memory_bytes: 45484
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 100'005
vi v[N];
vi u;

void ng(){
	printf("No\n");
	exit(0);
}

void ok(){
	printf("Yes\n");
	exit(0);
}

int main(){
	int n, m; scanf("%d%d", &n, &m);
	REP(i, m){
		int a, b; scanf("%d%d", &a, &b); a--; b--;
		v[a].EB(b);
		v[b].EB(a);
	}
	REP(i, n){
	 	if(v[i].size()%2) ng();
		if(v[i].size()>=4) u.EB(i);
	}
	if(u.size()==0) ng();
	if(u.size()==1){
		if(v[u[0]].size()==4) ng();
		else ok();
	}
	if(u.size()>=3) ok();
	int p=u[0], q=u[1];
	DEBUG("%d %d\n", p, q);
	if(v[p].size() > 4 || v[q].size()>4) ok();
	for(int i:v[p]){
		int a=i, b=p;
		DEBUG("%d=>%d ", b, a);
		while(a!=p && a!=q){
			int d=a;
			// DEBUG("a=%d[", a);
			// for(int j:v[a]) printf("%d ", j);
			// DEBUG("] ");
			if(v[a][0]!=b) a=v[a][0]; 
			else a=v[a][1];
			b=d;
			DEBUG("%d=>%d ", b, a);
		}
		DEBUG("\n");
		if(a==p) ok();
	}
	ng();
}


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

using namespace std;

long long int f(int a, int b) {
    long long int aa = 0, bb = 0;
    while (a) {
        aa++;
        a /= 10;
    }
    while (b) {
        bb++;
        b /= 10;
    }
    return max(aa, bb);
}
int main() {
    long long int n;
    cin >> n;

    long long int m = INT64_MAX;
    for (long long int i = 1; i * i <= n; i++) {
        if (!(n % i))
            m = min(m, f(i, n / i));
    }

    cout << m << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
#ABC115 D

n,x = map(int,input().split())

burger = [0]*(n+1)#厚み
p = [0]*(n+1)#パテの数
burger[0],p[0] = 1,1
for i in range(n):
    p[i+1] = 2*p[i]+1
    burger[i+1] = 2*burger[i]+3

def f(n,x):
    if n == 0:
        if x <= 0:
            return 0
        else:
            return 1
    if x == 1:
        if n == 0:
            return 1
        else:
            return 0
    elif x <= burger[n-1] + 1:
        return f(n-1,x-1)
    elif x == burger[n-1] + 2:
        return p[n-1] + 1
    elif burger[n-1] + 2 < x <= 2*burger[n-1] + 2:
        return p[n-1] + 1 + f(n-1,x-2-burger[n-1])
    elif x == 2*burger[n-1] + 3:
        return 2*p[n-1] + 1
ans = f(n,x)
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include<iomanip>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define ffrvs(ii,nn,mm) for(int ii=nn;ii>=mm;ii--)
#define srt(vvv) sort(vvv.begin(),vvv.end())
#define srtrvs(vvv) reverse(vvv.begin(),vvv.end())
#define Graph vector<vector<int>>

i64 inf = 1000000007;
i64 giant = 4000000000000000037;

using namespace std;

i64 cup(i64 xxx, i64 yyy) {//切り上げ
	return (xxx + yyy - 1) / yyy;
}

//メモリ置き場
int n;
vector<vector<int>> bingo(3,vector<int>(3));
set<int> num;

//inputします
void input() {
	ff(i, 0, 3) {
		ff(j, 0, 3) {
			cin >> bingo[i][j];
		}
	}
	cin >> n;
	ff(i, 0, n) {
		int b;
		cin >> b;
		num.insert(b);
	}
}

//ライブラリ置き場

//main
int main() {
	input();
	int ans = 0;
	ff(i, 0, 3) {
		ff(j, 0, 3) {
			if (num.count(bingo[i][j]))bingo[i][j] = 0;
		}
	}
	ff(i, 0, 3) {
		if (bingo[i][0] + bingo[i][1] + bingo[i][2] == 0)ans++;
		if (bingo[0][i] + bingo[1][i] + bingo[2][i] == 0)ans++;
	}
	if (bingo[0][0] + bingo[1][1] + bingo[2][2] == 0)ans++;
	if (bingo[0][2] + bingo[1][1] + bingo[2][0] == 0)ans++;
	if (ans == 0)cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

using ll = long long;

ll N, P;
map<ll,int> factors;

void solve()
{
	for(long long i=2;i*i<=P; ++i){
		if(P%i==0){
			int cnt=0;
			while(P%i==0){
				P/=i;
				cnt++;
			}
			factors[i]=cnt;
		}
	}
	if(P!=1) factors[P]=1;
	ll ans = 1;
	for(auto it=factors.begin(); it!=factors.end(); ++it){
		if(it->second >=N) ans *= pow(it->first, (it->second)/N);
	}
	cout << ans << endl;
}

int main()
{
	cin >> N >> P;
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;


int main(){
  char C;
  string s ="abcdefghijklmnopqrstuvwxyz";
  cin >> C;
  for(int i=0;i<26;i++){
    if(C == s[i]){
      cout << s[i+1]; return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 256
//"BISMILLAHIR RAHMANIR RAHIM"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
const long long M = 1e9+7 ;
ll fact(ll x, ll y){
    ll f=1,i=1;
    while(i<=y){
        f=( (f%M) * (x%M) )%M;
        i++;
    }
    return f;
}
int main()
{
    ll n,i,cnt=0,x,y;
    cin>>n;
    vector<pair< ll,ll >>p;
    for(i=0;i<n;i++){
        cin>>x>>y;
        p.pb({x,y});
    }
    bool f=0;
    for(i=0;i<n;i++){
        if(p[i].first==p[i].second)
            cnt++;
        else
            cnt=0;
        if(cnt>=3)
            f=1;
    }
    if(f)
    cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return 0;
}




Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

string s, t, u;
int a, b;

signed main() {
	cin >> s >> t >> a >> b >> u;
	if (s == u)cout << a - 1 << " " << b << endl;
	else cout << a << " " << b - 1 << endl;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define forp(i,a,b) for (int i = (a); i <(b); i++)
#define forn(i,a,b) for (int i = (a); i >(b); i--)
#define mod 1000000007
#define multiple_testcases_t int t;cin>>t;while(t--){solve();}
#define single_testcase_t solve();
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

long long int modular_exponentiation(long long int x,long long int n)
{
    if(n==1)
    return x;

    if(n%2)
    {
        return (x*(modular_exponentiation(x,(n-1)/2)%mod)*(modular_exponentiation(x,(n-1)/2)%mod))%mod;
    }
    else
    {
        return ((modular_exponentiation(x,n/2)%mod)*(modular_exponentiation(x,n/2)%mod))%mod;
    }
}
// <----- Actual solve() function to print output -----> //
void solve()
{
   ll n,p,q,x,y,k=0;
string s;
  cin>>s;
  n=s.size();
  if(s[n-1]=='s')
  {
    cout<<s;
    cout<<"es";
  }
  else
    cout<<s<<"s";

   //cout<<"\n";      //if t>1 uncomment this
}
 
// MAIN function --------------------------------------------------------------------------//
int main()
{
    fast_io
//  freopen("input.txt", "r", stdin);
//  freopen("output.txt", "w", stdout);
 
  single_testcase_t
 // multiple_testcases_t
return 0;
}


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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

ll S, T;
string s, t;
ll dp[4000][4000];

ll dpf(ll i, ll j){
  if(i<0 or j<0)return 0;
  if(dp[i][j]>=0)return dp[i][j];
  else{
    dp[i][j]=0;
    if(i==0 and j==0){
      if(s[i]==t[j])dp[i][j]=1;
    }else{
      dp[i][j]=max(dpf(i-1,j), dp[i][j]);
      dp[i][j]=max(dpf(i,j-1), dp[i][j]);
      if(s[i]==t[j]) dp[i][j]=max(dpf(i-1,j-1)+1, dp[i][j]);
    }
    return dp[i][j];
  }
}

/**************************************
** A main function starts from here  **
***************************************/
int main(){
  cin >> s >> t;
  S = s.size();
  T = t.size();
  fill(dp[0], dp[4000], -10);
  ll tmp = dpf(S-1, T-1);
  //cout << tmp << endl;
  string ans="";
  ll si=S-1;
  ll ti=T-1;
  while(ans.size()<tmp and si>=0 and ti>=0){
    //cout << ans << " " << si << " " << ti << endl;
    if(dpf(si,ti)==dpf(si-1, ti)){
      si = si-1;
      continue;
    }
    if(dpf(si,ti)==dpf(si, ti-1)){
      ti = ti-1;
      continue;
    }
    if(s[si]==t[ti] and dpf(si,ti)==(dpf(si-1, ti-1)+1)){
      ans = s[si] + ans;
      si = si-1;
      ti = ti-1;
      //cout << ans << endl;
      continue;
    }
    si--;
    ti--;
  }

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


Measured memory_bytes: 125568
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>

const int N = 2e5 + 52;
struct edge {
	int to, next, w;
} e[N << 1];
int n, head[N], cnt;
void ad(int x, int y, int z) { e[++cnt] = {y, x[head], z}, x[head] = cnt; }

std::queue<int> q;
int dis[N];
int main() {
	memset(head, -1, sizeof head);
	memset(dis, 0x3f, sizeof dis), dis[1] = 1;
	scanf("%d", &n);
	for (int i = 1; i < n; i++) ad(i, (i + 1) % n, 1);
	for (int i = 1; i < n; i++) ad(i, i * 10 % n, 0);
	for (q.push(1); !q.empty(); q.pop())
		for (int x = q.front(), i = x[head], nx; ~i; i = e[i].next)
			if ((nx = e[i].to)[dis] > x[dis] + e[i].w) nx[dis] = x[dis] + e[i].w, q.push(nx);
	printf("%d", 0 [dis]);
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<ll> vec){
    ll n = vec.size();
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
}

void pr2d(vector<vector<ll>> vvec){
    ll h = vvec.size();
    ll w = vvec.at(0).size();
    rep(i,h){
        rep(j,w){
            cout << vvec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
}

ll h,w,ch,cw,dh,dw;
vector<string> b;
vector<vector<ll>> wp;

bool is_valid(ll y, ll x){
  if(y<0 || y>=h || x<0 || x>=w) return false;
  if(b.at(y).at(x) == '#') return false;
  return true;
}

int main(){
    cin >> h >> w >> ch >> cw >> dh >> dw;
    ch--, cw--, dh--, dw--;
    b.resize(h);
    wp.resize(h,vector<ll>(w,-1));
    rep(i,h) cin >> b.at(i);

    deque<pair<ll,ll>> q;
    q.push_front(make_pair(ch,cw));
    wp.at(ch).at(cw) = 0;
    vector<vector<ll>> chkd(h,vector<ll>(w,0));

    while(q.size()){
        pair<ll,ll> p = q.front();
        q.pop_front();
        if(chkd.at(p.first).at(p.second)) continue;
        ll cur = wp.at(p.first).at(p.second);
        for(int vh = p.first - 2; vh<=p.first + 2;vh++){
            for(int vw = p.second - 2; vw<=p.second + 2;vw++){
                ll diff = abs(p.first - vh) + abs(p.second - vw);
                if(diff == 0){
                    continue;
                }else if(diff ==  1){
                    if(is_valid(vh,vw)){
                        wp.at(vh).at(vw) = cur;
                        q.push_front(make_pair(vh,vw));
                    }
                }else{
                    if(is_valid(vh,vw)){
                        if(wp.at(vh).at(vw)==-1 || wp.at(vh).at(vw) > cur + 1){
                            wp.at(vh).at(vw) = cur + 1;
                            q.push_back(make_pair(vh,vw));
                        }
                    }
                }
            }
        }
        chkd.at(p.first).at(p.second)=1;
    }

    cout << wp.at(dh).at(dw) << endl;
    return 0;
}

Measured memory_bytes: 21336
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#include <stack>
#include <queue>
#include <deque>

using namespace std;

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

#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define mkp make_pair
#define F first
#define S second
#define show(a) cerr << #a <<" -> "<< a <<"\n"
#define fo(a, b, c, d) for(int (a) = (b); (a) <= (c); (a) += (d))
#define foo(a, b, c ,d) for(int (a) = (b); (a) >= (c); (a) -= (d))
//#define int ll

const int N = 2000;
const int MOD = 1e9 + 7;

int n, m, dp[N][N];
char c[N][N];

int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> m;
	fo(i, 1, n, 1) {
		fo(j, 1, m, 1) {
			cin >> c[i][j];
		}
	}
	dp[1][1] = 1;
	fo(i, 1, n, 1) {
		fo(j, 1, m, 1) {
			if(c[i][j] == '#') continue;
			if(c[i - 1][j] == '.') dp[i][j] += dp[i - 1][j];
			if(c[i][j - 1] == '.') dp[i][j] += dp[i][j - 1];
			dp[i][j] %= MOD;
		}
	}
	cout << dp[n][m];
	return 0;
}
/*
	If you only do what you can do, 
	You will never be more than you are now!
	----------------------------------------
	We must all suffer from one of two pains: the pain of discipline or the pain of regret. 
	The difference is discipline weighs grams while regret weighs tons.
*/


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

const unsigned long long int mod = 1e9+7;
unsigned long long int dp[100005][13];

int main(){
	string s;
	cin >> s;
	
	dp[0][0] = 1;
	for(int i=0;i<s.size();++i){
		for(int j=0;j<13;++j){
			
			if(s[i] == '?'){
				for(int c=0;c<10;++c){
					dp[i+1][(10*j+c)%13] += dp[i][j];
				}
			}else{
				int c = s[i] -'0';
				dp[i+1][(10*j+c)%13] += dp[i][j];
			}
		}
		for(int j=0;j<13;++j)
			dp[i+1][j] %= mod;
	}
	
	/*
	for(int i=0;i<s.size();++i){
		for(int j=0;j<13;++j){
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}*/
	
	cout << dp[s.size()][5];
	
	return 0;
}



Measured memory_bytes: 10624
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(x) (x).begin(),(x).end()
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    ll n;cin>>n;
    string s;cin>>s;
    ll ans=0;
    for(ll i=0;i<n;i++){
        ll t=0;
        for(int j=0;j<n-i;j++){
            t=(t+1)*(s[j]==s[j+i]);
            ans=max(ans,min(i,t));
        }
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 384
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
a, b = map(int,input().split())
a_set = set()
for tmp in factorization(a):
    num = tmp[0]
    if num not in a_set:
        a_set.add(num)
b_set = set()
for tmp in factorization(b):
    num = tmp[0]
    if num not in b_set:
        b_set.add(num)
ans = a_set & b_set
if 1 not in ans:
    ans.add(1)
print(len(ans))

Measured memory_bytes: 3064
a, b, c, x, y = map(int, input().split())
# print(a, b, c, x, y)

ans = 10000 * (10 **5) + 7
c_max = 0
if x > y:
  c_max = x * 2
else:
  c_max = y * 2

for cc in range(0, c_max+1, 2):
  ac = x - (cc // 2)
  bc = y - (cc // 2)
  
  if ac < 0:
    ac = 0
  if bc < 0:
    bc = 0
  price = ac * a + bc * b + cc * c
  # print('price: {}, ac: {}, bc: {}, cc: {}'.format(price, ac, bc, cc))
  ans = min(ans, price)

print(ans)
  

Measured memory_bytes: 65396
#include <map>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <queue>

using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

class Matching {
private:
  int nL, nR;
  vector<vector<int> > g; // g[vL][i] = vR
  vector<int> matching, dist;
  bool dfs(int vL) {
    REP(i, g[vL].size()){
      int vR = g[vL][i];
      int nextL = matching[vR];
      if(nextL == -1 || (dist[nextL] == dist[vL] + 1 && dfs(nextL))){
        matching[vR] = vL;
        matching[vL] = vR;
        return true;
      }
    }
    dist[vL] = -3;
    return false;
  }
  bool bfs() {
    bool res = false;
    queue<int> q;
    dist.assign(nL, -3);
    REP(vL, nL)
      if(matching[vL] == -1)
        q.push(vL), dist[vL] = 0;
    while(!q.empty()){
      int vL = q.front(); q.pop();
      REP(i, g[vL].size()){
        int nextL = matching[g[vL][i]];
        if(nextL == -1)
          res = true;
        else if(dist[nextL] == -3)
          q.push(nextL), dist[nextL] = dist[vL]+1;
      }
    }
    return res;
  }
public:
  Matching(int nL, int nR) : nL(nL), nR(nR), g(nL) {}
  void addEdge(int vL, int vR) { g[vL].push_back(nL+vR); }
  int match() {
    int res = 0;
    for(matching.assign(nL+nR, -1); bfs(); )
      REP(vL, nL)
        res += matching[vL] == -1 && dfs(vL);
    return res;
  }
  int partner(int vR) { return matching[nL+vR]; }
};


struct P {
  int x, y;
};

P rs[110];
P bs[110];

int main(void) {
  int n;
  scanf("%d", &n);
  REP(i, n) {
    scanf("%d%d", &rs[i].x, &rs[i].y);
  }
  REP(i, n) {
    scanf("%d%d", &bs[i].x, &bs[i].y);
  }

  Matching m(n, n);
  REP(i, n) {
    REP(j, n) {
      if(rs[i].x < bs[j].x && rs[i].y < bs[j].y) {
        m.addEdge(i, j);
      }
    }
  }
  int res = m.match();
  printf("%d\n", res);

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int a, p; cin >> a >> p;
  p += a * 3;
  cout << p / 2 << '\n';
  return 0;
}


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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;

int main()
{
  string S;
  cin >> S;
  bool ok = true;
  for (int i = 0; i < S.size(); i++)
  {
    if (i % 2 == 0)
    {
      if (!(S[i] == 'R' || S[i] == 'U' || S[i] == 'D'))
        ok = false;
    }
    else
    {
      if (!(S[i] == 'L' || S[i] == 'U' || S[i] == 'D'))
        ok = false;
    }
  }
  if (ok)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

bool solve() {
    ll N, a;
    cin >> N;
    ll c = 0;
    for ( int i = 0; i < N; i++ ) {
        cin >> a;
        c += (a & 1);
    }
    return (c & 1) == 0;
}

int main() {
    string ans = solve() ? "YES" : "NO";
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll p0[2005],p1[2005],hv0[4005][2005],hv1[4005][2005];
ll dp[2005][2005];
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n;cin>>n;
    for(ll i=0;i<2*n;i++){
        char ch;cin>>ch;
        ll x;cin>>x;
        if(ch=='W')p0[x]=i;
        else p1[x]=i;
    }
    for(ll i=0;i<2*n;i++){
        hv0[i][0]=0;
        for(ll j=1;j<=n;j++)hv0[i][j]=hv0[i][j-1] + (p0[j]>i);
    }
    for(ll i=0;i<2*n;i++){
        hv1[i][0]=0;
        for(ll j=1;j<=n;j++)hv1[i][j]=hv1[i][j-1] + (p1[j]>i);
    }
    for(ll i=0;i<=n;i++){
        for(ll j=0;j<=n;j++){
            if(i==0 && j==0)continue;
            dp[i][j]=1e9;
            if(i>0)dp[i][j]=min(dp[i][j], dp[i-1][j] + hv0[p0[i]][i] + hv1[p0[i]][j]);
            if(j>0)dp[i][j]=min(dp[i][j], dp[i][j-1] + hv0[p1[j]][i] + hv1[p1[j]][j]);
        }
    }
    cout<<dp[n][n];
}

Measured memory_bytes: 157056
n = int(input())
li = list(map(int, input().split()))


def check(n, li):
    count = 0
    odd = False
    while True:
        for i in range(n):
            if li[i] % 2 == 0:
                li[i] /= 2
            else:
                print(count)
                odd = True
                break
        if odd:
            break
        count += 1


check(n, li)


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int d = sc.nextInt();
		int n = sc.nextInt();
		int ans;
		
		if(n < 100)
			ans = n*(int)Math.pow(100, d);
		else
			ans = (n+1)*(int)Math.pow(100, d);
		
		System.out.println(ans);
		
	}
}


Measured memory_bytes: 21716